You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(107) |
Dec
(67) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(76) |
Feb
(125) |
Mar
(72) |
Apr
(13) |
May
(18) |
Jun
(12) |
Jul
(129) |
Aug
(47) |
Sep
(1) |
Oct
(36) |
Nov
(128) |
Dec
(124) |
2002 |
Jan
(59) |
Feb
|
Mar
(14) |
Apr
(14) |
May
(72) |
Jun
(9) |
Jul
(3) |
Aug
(5) |
Sep
(18) |
Oct
(65) |
Nov
(28) |
Dec
(12) |
2003 |
Jan
(10) |
Feb
(2) |
Mar
(4) |
Apr
(33) |
May
(21) |
Jun
(9) |
Jul
(29) |
Aug
(34) |
Sep
(4) |
Oct
(8) |
Nov
(15) |
Dec
(4) |
2004 |
Jan
(26) |
Feb
(12) |
Mar
(11) |
Apr
(9) |
May
(7) |
Jun
|
Jul
(5) |
Aug
|
Sep
(3) |
Oct
(7) |
Nov
(1) |
Dec
(10) |
2005 |
Jan
(2) |
Feb
(72) |
Mar
(16) |
Apr
(39) |
May
(48) |
Jun
(97) |
Jul
(57) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(100) |
Dec
(24) |
2006 |
Jan
(15) |
Feb
(34) |
Mar
(33) |
Apr
(31) |
May
(79) |
Jun
(64) |
Jul
(41) |
Aug
(64) |
Sep
(31) |
Oct
(46) |
Nov
(55) |
Dec
(37) |
2007 |
Jan
(32) |
Feb
(61) |
Mar
(11) |
Apr
(58) |
May
(46) |
Jun
(30) |
Jul
(94) |
Aug
(93) |
Sep
(86) |
Oct
(69) |
Nov
(125) |
Dec
(177) |
2008 |
Jan
(169) |
Feb
(97) |
Mar
(74) |
Apr
(113) |
May
(120) |
Jun
(334) |
Jul
(215) |
Aug
(237) |
Sep
(72) |
Oct
(189) |
Nov
(126) |
Dec
(160) |
2009 |
Jan
(180) |
Feb
(45) |
Mar
(98) |
Apr
(140) |
May
(151) |
Jun
(71) |
Jul
(107) |
Aug
(119) |
Sep
(73) |
Oct
(121) |
Nov
(14) |
Dec
(6) |
2010 |
Jan
(13) |
Feb
(9) |
Mar
(10) |
Apr
(64) |
May
(3) |
Jun
(16) |
Jul
(7) |
Aug
(23) |
Sep
(17) |
Oct
(37) |
Nov
(5) |
Dec
(8) |
2011 |
Jan
(10) |
Feb
(11) |
Mar
(77) |
Apr
(11) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <fwi...@us...> - 2008-08-03 20:17:42
|
Revision: 5071 http://jython.svn.sourceforge.net/jython/?rev=5071&view=rev Author: fwierzbicki Date: 2008-08-03 20:17:40 +0000 (Sun, 03 Aug 2008) Log Message: ----------- Partial fix for #1092 (just a comment no newline). Modified Paths: -------------- branches/asm/grammar/Python.g Modified: branches/asm/grammar/Python.g =================================================================== --- branches/asm/grammar/Python.g 2008-08-03 18:18:34 UTC (rev 5070) +++ branches/asm/grammar/Python.g 2008-08-03 20:17:40 UTC (rev 5071) @@ -1418,6 +1418,6 @@ $channel=HIDDEN; } : {startPos==0}?=> (' '|'\t')* '#' (~'\n')* '\n'+ - | {startPos>0}?=> '#' (~'\n')* // let NEWLINE handle \n unless char pos==0 for '#' + | '#' (~'\n')* // let NEWLINE handle \n unless char pos==0 for '#' ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-08-03 18:18:36
|
Revision: 5070 http://jython.svn.sourceforge.net/jython/?rev=5070&view=rev Author: pjenvey Date: 2008-08-03 18:18:34 +0000 (Sun, 03 Aug 2008) Log Message: ----------- o FileIO whitespace, small refactor o re-enable test_ast Modified Paths: -------------- branches/asm/Lib/test/regrtest.py branches/asm/src/org/python/core/io/FileIO.java Modified: branches/asm/Lib/test/regrtest.py =================================================================== --- branches/asm/Lib/test/regrtest.py 2008-08-03 18:14:53 UTC (rev 5069) +++ branches/asm/Lib/test/regrtest.py 2008-08-03 18:18:34 UTC (rev 5070) @@ -1467,7 +1467,6 @@ _failures = { 'java': """ - test_ast test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp Modified: branches/asm/src/org/python/core/io/FileIO.java =================================================================== --- branches/asm/src/org/python/core/io/FileIO.java 2008-08-03 18:14:53 UTC (rev 5069) +++ branches/asm/src/org/python/core/io/FileIO.java 2008-08-03 18:18:34 UTC (rev 5070) @@ -69,8 +69,8 @@ if (fullPath.isDirectory()) { throw Py.IOError(errno.EISDIR, "Is a directory"); } - if ( (writable && !fullPath.canWrite()) || - fnfe.getMessage().endsWith("(Permission denied)")) { + if ((writable && !fullPath.canWrite()) + || fnfe.getMessage().endsWith("(Permission denied)")) { throw Py.IOError(errno.EACCES, "Permission denied: '" + name + "'"); } throw Py.IOError(errno.ENOENT, "No such file or directory: '" + name + "'"); @@ -178,10 +178,11 @@ /** {@inheritDoc} */ public boolean isatty() { checkClosed(); - if (file == null) return false; - + if (file == null) { + return false; + } try { - return imp.load("os").__getattr__("isatty").__call__(Py.java2py(file.getFD())).__nonzero__(); + return imp.load("os").invoke("isatty", Py.java2py(file.getFD())).__nonzero__(); } catch (IOException e) { return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-08-03 18:14:55
|
Revision: 5069 http://jython.svn.sourceforge.net/jython/?rev=5069&view=rev Author: pjenvey Date: 2008-08-03 18:14:53 +0000 (Sun, 03 Aug 2008) Log Message: ----------- expand tabs Modified Paths: -------------- branches/asm/src/org/python/core/io/FileIO.java Modified: branches/asm/src/org/python/core/io/FileIO.java =================================================================== --- branches/asm/src/org/python/core/io/FileIO.java 2008-08-03 16:30:08 UTC (rev 5068) +++ branches/asm/src/org/python/core/io/FileIO.java 2008-08-03 18:14:53 UTC (rev 5069) @@ -59,10 +59,10 @@ File fullPath = new RelativeFile(name); String rafMode = "r" + (writable ? "w" : ""); try { - if (plus && mode.charAt(0) == 'r' && !fullPath.isFile()) { - writable = false; - throw new FileNotFoundException(""); - } + if (plus && mode.charAt(0) == 'r' && !fullPath.isFile()) { + writable = false; + throw new FileNotFoundException(""); + } file = new RandomAccessFile(fullPath, rafMode); fileChannel = file.getChannel(); } catch (FileNotFoundException fnfe) { @@ -70,7 +70,7 @@ throw Py.IOError(errno.EISDIR, "Is a directory"); } if ( (writable && !fullPath.canWrite()) || - fnfe.getMessage().endsWith("(Permission denied)")) { + fnfe.getMessage().endsWith("(Permission denied)")) { throw Py.IOError(errno.EACCES, "Permission denied: '" + name + "'"); } throw Py.IOError(errno.ENOENT, "No such file or directory: '" + name + "'"); @@ -163,13 +163,13 @@ try { fileChannel.truncate(0); } catch (IOException ioe) { - // On Solaris and Linux, ftruncate(3C) returns EINVAL - // if not a regular file whereas, e.g., - // open("/dev/null", "w") works fine. Because we have - // to simulate the "w" mode in Java, we suppress the - // exception. - if (ioe.getMessage().equals("Invalid argument")) - return; + // On Solaris and Linux, ftruncate(3C) returns EINVAL + // if not a regular file whereas, e.g., + // open("/dev/null", "w") works fine. Because we have + // to simulate the "w" mode in Java, we suppress the + // exception. + if (ioe.getMessage().equals("Invalid argument")) + return; throw Py.IOError(ioe); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-03 16:30:11
|
Revision: 5068 http://jython.svn.sourceforge.net/jython/?rev=5068&view=rev Author: fwierzbicki Date: 2008-08-03 16:30:08 +0000 (Sun, 03 Aug 2008) Log Message: ----------- Small change for Jython -- it will be too hard in the short term to use CPython's "Store" where Jython uses "AugStore" for AugAssigns. Eventually I do intend to fix this, but it will take a little more work in the compiler than I want to do just now. Modified Paths: -------------- branches/asm/Lib/test/test_ast.py Modified: branches/asm/Lib/test/test_ast.py =================================================================== --- branches/asm/Lib/test/test_ast.py 2008-08-03 14:42:44 UTC (rev 5067) +++ branches/asm/Lib/test/test_ast.py 2008-08-03 16:30:08 UTC (rev 5068) @@ -171,6 +171,7 @@ assert to_tuple(ast_tree) == o test_order(ast_tree, (0, 0)) +# XXX: AugStore added for Jython. Short term it is too hard to emit just "Store" as CPython does. #### EVERYTHING BELOW IS GENERATED ##### exec_results = [ ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Pass', (1, 9))], [])]), @@ -178,7 +179,7 @@ ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Return', (1, 8), ('Num', (1, 15), 1))], [])]), ('Module', [('Delete', (1, 0), [('Name', (1, 4), 'v', ('Del',))])]), ('Module', [('Assign', (1, 0), [('Name', (1, 0), 'v', ('Store',))], ('Num', (1, 4), 1))]), -('Module', [('AugAssign', (1, 0), ('Name', (1, 0), 'v', ('Store',)), ('Add',), ('Num', (1, 5), 1))]), +('Module', [('AugAssign', (1, 0), ('Name', (1, 0), 'v', ('AugStore',)), ('Add',), ('Num', (1, 5), 1))]), ('Module', [('Print', (1, 0), ('Name', (1, 8), 'f', ('Load',)), [('Num', (1, 11), 1)], False)]), ('Module', [('For', (1, 0), ('Name', (1, 4), 'v', ('Store',)), ('Name', (1, 9), 'v', ('Load',)), [('Pass', (1, 11))], [])]), ('Module', [('While', (1, 0), ('Name', (1, 6), 'v', ('Load',)), [('Pass', (1, 8))], [])]), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-03 14:42:47
|
Revision: 5067 http://jython.svn.sourceforge.net/jython/?rev=5067&view=rev Author: fwierzbicki Date: 2008-08-03 14:42:44 +0000 (Sun, 03 Aug 2008) Log Message: ----------- Passed filename along to parsers and PythonTokenSource. created a PyIndentationError to allow me derive IndentationErrors from ParseException. Added a "type" to ParseException to recognize when an IndentationError is needed. Changed test_traceback slightly because I believe Antlr comes up with a better placement for the carot vs CPython (at the indent and not end of line for indent errors. Modified Paths: -------------- branches/asm/Lib/test/test_traceback.py branches/asm/src/org/python/antlr/BaseParser.java branches/asm/src/org/python/antlr/ExpressionParser.java branches/asm/src/org/python/antlr/InteractiveParser.java branches/asm/src/org/python/antlr/ModuleParser.java branches/asm/src/org/python/antlr/ParseException.java branches/asm/src/org/python/antlr/PythonTokenSource.java branches/asm/src/org/python/core/ParserFacade.java branches/asm/src/org/python/core/PySyntaxError.java branches/asm/tests/java/org/python/antlr/PythonTreeTester.java Added Paths: ----------- branches/asm/src/org/python/core/PyIndentationError.java Modified: branches/asm/Lib/test/test_traceback.py =================================================================== --- branches/asm/Lib/test/test_traceback.py 2008-08-03 09:50:01 UTC (rev 5066) +++ branches/asm/Lib/test/test_traceback.py 2008-08-03 14:42:44 UTC (rev 5067) @@ -50,7 +50,9 @@ self.assert_(len(err) == 4) self.assert_(err[1].strip() == "print 2") self.assert_("^" in err[2]) - self.assert_(err[1].find("2") == err[2].find("^")) + # Antlr thinks the error is at the indentation, while CPython points at + # the end of the line. I am agreeing with Antlr over CPython here. + self.assert_(err[1].find("p") -1 == err[2].find("^")) def test_bug737473(self): import sys, os, tempfile, time Modified: branches/asm/src/org/python/antlr/BaseParser.java =================================================================== --- branches/asm/src/org/python/antlr/BaseParser.java 2008-08-03 09:50:01 UTC (rev 5066) +++ branches/asm/src/org/python/antlr/BaseParser.java 2008-08-03 14:42:44 UTC (rev 5067) @@ -28,6 +28,7 @@ protected CharStream charStream; protected boolean partial; + protected String filename; protected ErrorHandler errorHandler = new FailFastHandler(); public void setAntlrErrorHandler(ErrorHandler eh) { Modified: branches/asm/src/org/python/antlr/ExpressionParser.java =================================================================== --- branches/asm/src/org/python/antlr/ExpressionParser.java 2008-08-03 09:50:01 UTC (rev 5066) +++ branches/asm/src/org/python/antlr/ExpressionParser.java 2008-08-03 14:42:44 UTC (rev 5067) @@ -16,8 +16,9 @@ public class ExpressionParser extends BaseParser { - public ExpressionParser(CharStream cs) { + public ExpressionParser(CharStream cs, String filename) { this.charStream = cs; + this.filename = filename; } public modType parse() { @@ -26,7 +27,7 @@ lexer.setErrorHandler(errorHandler); CommonTokenStream tokens = new CommonTokenStream(lexer); tokens.discardOffChannelTokens(true); - PythonTokenSource indentedSource = new PythonTokenSource(tokens); + PythonTokenSource indentedSource = new PythonTokenSource(tokens, filename); tokens = new CommonTokenStream(indentedSource); PythonParser parser = new PythonParser(tokens); parser.setErrorHandler(errorHandler); Modified: branches/asm/src/org/python/antlr/InteractiveParser.java =================================================================== --- branches/asm/src/org/python/antlr/InteractiveParser.java 2008-08-03 09:50:01 UTC (rev 5066) +++ branches/asm/src/org/python/antlr/InteractiveParser.java 2008-08-03 14:42:44 UTC (rev 5067) @@ -32,8 +32,9 @@ } } - public InteractiveParser(BufferedReader br) { + public InteractiveParser(BufferedReader br, String filename) { this.bufreader = br; + this.filename = filename; } public modType parse() throws IOException { @@ -44,7 +45,7 @@ lexer.inSingle = true; CommonTokenStream tokens = new CommonTokenStream(lexer); tokens.discardOffChannelTokens(true); - PythonTokenSource indentedSource = new PythonTokenSource(tokens); + PythonTokenSource indentedSource = new PythonTokenSource(tokens, filename); tokens = new CommonTokenStream(indentedSource); PythonParser parser = new PythonParser(tokens); parser.setErrorHandler(errorHandler); Modified: branches/asm/src/org/python/antlr/ModuleParser.java =================================================================== --- branches/asm/src/org/python/antlr/ModuleParser.java 2008-08-03 09:50:01 UTC (rev 5066) +++ branches/asm/src/org/python/antlr/ModuleParser.java 2008-08-03 14:42:44 UTC (rev 5067) @@ -15,13 +15,14 @@ import org.python.antlr.ast.stmtType; public class ModuleParser extends BaseParser { - public ModuleParser(CharStream cs) { - this(cs, false); + public ModuleParser(CharStream cs, String filename) { + this(cs, filename, false); } - public ModuleParser(CharStream cs, boolean partial) { + public ModuleParser(CharStream cs, String filename, boolean partial) { this.partial = partial; this.charStream = cs; + this.filename = filename; } public modType file_input() { @@ -30,7 +31,7 @@ lexer.setErrorHandler(errorHandler); CommonTokenStream tokens = new CommonTokenStream(lexer); tokens.discardOffChannelTokens(true); - PythonTokenSource indentedSource = new PythonTokenSource(tokens); + PythonTokenSource indentedSource = new PythonTokenSource(tokens, filename); tokens = new CommonTokenStream(indentedSource); PythonParser parser = new PythonParser(tokens); parser.setErrorHandler(errorHandler); Modified: branches/asm/src/org/python/antlr/ParseException.java =================================================================== --- branches/asm/src/org/python/antlr/ParseException.java 2008-08-03 09:50:01 UTC (rev 5066) +++ branches/asm/src/org/python/antlr/ParseException.java 2008-08-03 14:42:44 UTC (rev 5067) @@ -1,6 +1,9 @@ package org.python.antlr; import org.python.antlr.PythonTree; +import org.python.core.Py; +import org.python.core.PyObject; + import org.antlr.runtime.*; public class ParseException extends RuntimeException { @@ -13,28 +16,49 @@ public int charPositionInLine; public boolean approximateLineInfo; + private PyObject type = Py.SyntaxError; + public ParseException() { super(); } - public ParseException(String message) { + public ParseException(String message, int lin, int charPos) { super(message); + this.line = lin; + this.charPositionInLine = charPos; } - public ParseException(String message, PythonTree node) { - super(message); + public ParseException(String message) { + this(message, 0, 0); } + /** + * n must not be null to use this constructor + */ + public ParseException(String message, PythonTree n) { + this(message, n.getLine(), n.getCharPositionInLine()); + this.node = n; + this.token = n.token; + } + public ParseException(String message, RecognitionException r) { super(message); - input = r.input; - index = r.index; - token = r.token; - node = r.node; - c = r.c; - line = r.line; - charPositionInLine = r.charPositionInLine; - approximateLineInfo = r.approximateLineInfo; + this.input = r.input; + this.index = r.index; + this.token = r.token; + this.node = r.node; + this.c = r.c; + this.line = r.line; + this.charPositionInLine = r.charPositionInLine; + this.approximateLineInfo = r.approximateLineInfo; } + public void setType(PyObject t) { + this.type = t; + } + + public PyObject getType() { + return this.type; + } + } Modified: branches/asm/src/org/python/antlr/PythonTokenSource.java =================================================================== --- branches/asm/src/org/python/antlr/PythonTokenSource.java 2008-08-03 09:50:01 UTC (rev 5066) +++ branches/asm/src/org/python/antlr/PythonTokenSource.java 2008-08-03 14:42:44 UTC (rev 5067) @@ -1,5 +1,7 @@ package org.python.antlr; +import org.python.core.Py; + /* [The "BSD licence"] Copyright (c) 2004 Terence Parr and Loring Craymer @@ -88,11 +90,14 @@ int lastTokenAddedIndex = -1; + String filename; + public PythonTokenSource(PythonLexer lexer) { } - public PythonTokenSource(CommonTokenStream stream) { + public PythonTokenSource(CommonTokenStream stream, String filename) { this.stream = stream; + this.filename = filename; // "state" of indent level is FIRST_CHAR_POSITION push(FIRST_CHAR_POSITION); } @@ -265,9 +270,8 @@ if (i == -1 || i == -2) { return FIRST_CHAR_POSITION; } - ParseException p = new ParseException("unindent does not match any outer indentation level"); - p.line = t.getLine(); - p.charPositionInLine = t.getCharPositionInLine(); + ParseException p = new ParseException("unindent does not match any outer indentation level", t.getLine(), t.getCharPositionInLine()); + p.setType(Py.IndentationError); throw p; } @@ -282,7 +286,7 @@ //FIXME: needed this for the Antlr 3.1b interface change. public String getSourceName() { - return "XXX-need-real-name.py"; + return filename; } } Modified: branches/asm/src/org/python/core/ParserFacade.java =================================================================== --- branches/asm/src/org/python/core/ParserFacade.java 2008-08-03 09:50:01 UTC (rev 5066) +++ branches/asm/src/org/python/core/ParserFacade.java 2008-08-03 14:42:44 UTC (rev 5067) @@ -46,15 +46,15 @@ if (reader == null) { return ""; } + String text = null; try { - String text=null; for(int i=0; i < line; i++) { text = reader.readLine(); } return text; } catch (IOException ioe) { - return null; } + return text; } // if reader != null, reset it @@ -80,12 +80,9 @@ } String text=getLine(reader, line); String msg = e.getMessage(); - if (msg == null) { - msg = "XXX: missing msg"; + if (e.getType() == Py.IndentationError) { + return new PyIndentationError(msg, line, col, text, filename); } - if (text == null) { - text = "XXX: missing text"; - } return new PySyntaxError(msg, line, col, text, filename); } else return Py.JavaError(t); @@ -108,16 +105,16 @@ if (kind.equals("eval")) { bufreader = prepBufreader(new LeadingSpaceSkippingStream(bstream), cflags, filename); CharStream cs = new NoCloseReaderStream(bufreader); - ExpressionParser e = new ExpressionParser(cs); + ExpressionParser e = new ExpressionParser(cs, filename); node = e.parse(); } else if (kind.equals("single")) { bufreader = prepBufreader(bstream, cflags, filename); - InteractiveParser i = new InteractiveParser(bufreader); + InteractiveParser i = new InteractiveParser(bufreader, filename); node = i.parse(); } else if (kind.equals("exec")) { bufreader = prepBufreader(bstream, cflags, filename); CharStream cs = new NoCloseReaderStream(bufreader); - ModuleParser g = new ModuleParser(cs); + ModuleParser g = new ModuleParser(cs, filename); node = g.file_input(); } else { throw Py.ValueError("parse kind must be eval, exec, " + "or single"); @@ -150,7 +147,7 @@ StringUtil.toBytes(string)); BufferedInputStream bstream = bstream = new BufferedInputStream(bi); bufreader = prepBufreader(bstream, cflags, filename); - InteractiveParser i = new InteractiveParser(bufreader); + InteractiveParser i = new InteractiveParser(bufreader, filename); node = i.parse(); } else { throw Py.ValueError("parse kind must be eval, exec, " + "or single"); Added: branches/asm/src/org/python/core/PyIndentationError.java =================================================================== --- branches/asm/src/org/python/core/PyIndentationError.java (rev 0) +++ branches/asm/src/org/python/core/PyIndentationError.java 2008-08-03 14:42:44 UTC (rev 5067) @@ -0,0 +1,33 @@ +// Copyright (c) Corporation for National Research Initiatives +package org.python.core; + +/** + * A convenience class for creating Indentation errors. Note that the + * syntax error is still taken from Py.IndentationError. + * <p> + * Generally subclassing from PyException is not the right way + * of creating new exception classes. + */ + +public class PyIndentationError extends PyException { + int lineno, column; + String text; + String filename; + + public PyIndentationError(String s, int line, int column, String text, + String filename) + { + super(Py.IndentationError); + PyObject[] tmp = new PyObject[] { + new PyString(filename), new PyInteger(line), + new PyInteger(column), new PyString(text) + }; + + this.value = new PyTuple(new PyString(s), new PyTuple(tmp)); + + this.lineno = line; + this.column = column; + this.text = text; + this.filename = filename; + } +} Modified: branches/asm/src/org/python/core/PySyntaxError.java =================================================================== --- branches/asm/src/org/python/core/PySyntaxError.java 2008-08-03 09:50:01 UTC (rev 5066) +++ branches/asm/src/org/python/core/PySyntaxError.java 2008-08-03 14:42:44 UTC (rev 5067) @@ -2,7 +2,7 @@ package org.python.core; /** - * A convience class for creating Syntax errors. Note that the + * A convenience class for creating Syntax errors. Note that the * syntax error is still taken from Py.SyntaxError. * <p> * Generally subclassing from PyException is not the right way @@ -10,7 +10,8 @@ */ public class PySyntaxError extends PyException { - int lineno, column; + int lineno; + int column; String text; String filename; Modified: branches/asm/tests/java/org/python/antlr/PythonTreeTester.java =================================================================== --- branches/asm/tests/java/org/python/antlr/PythonTreeTester.java 2008-08-03 09:50:01 UTC (rev 5066) +++ branches/asm/tests/java/org/python/antlr/PythonTreeTester.java 2008-08-03 14:42:44 UTC (rev 5067) @@ -27,13 +27,17 @@ public PythonTree parse(String[] args) throws Exception { PythonTree result = null; + //ErrorHandler eh = new ListErrorHandler(); + ErrorHandler eh = new FailFastHandler(); CharStream input = new ANTLRFileStream(args[0]); PythonLexer lexer = new ModuleParser.PyLexer(input); + lexer.setErrorHandler(eh); CommonTokenStream tokens = new CommonTokenStream(lexer); tokens.discardOffChannelTokens(true); - PythonTokenSource indentedSource = new PythonTokenSource(tokens); + PythonTokenSource indentedSource = new PythonTokenSource(tokens, args[0]); tokens = new CommonTokenStream(indentedSource); PythonParser parser = new PythonParser(tokens); + parser.setErrorHandler(eh); parser.setTreeAdaptor(new PythonTreeAdaptor()); Tree r = null; switch (_block) { @@ -54,6 +58,7 @@ CommonTreeNodeStream nodes = new CommonTreeNodeStream(r); nodes.setTokenStream(tokens); PythonWalker walker = new PythonWalker(nodes); + walker.setErrorHandler(eh); switch (_block) { case MODULE : result = walker.module(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2008-08-03 09:50:04
|
Revision: 5066 http://jython.svn.sourceforge.net/jython/?rev=5066&view=rev Author: nriley Date: 2008-08-03 09:50:01 +0000 (Sun, 03 Aug 2008) Log Message: ----------- jna-posix from http://svn.codehaus.org/jruby-contrib/trunk/jna-posix r213 + patch in http://jira.codehaus.org/browse/JRUBY-2885 for isatty on Windows + patch in http://jira.codehaus.org/browse/JRUBY-2887 for atime setting (now with Windows support) Modified Paths: -------------- branches/asm/extlibs/jna-posix.jar This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2008-08-03 07:42:27
|
Revision: 5065 http://jython.svn.sourceforge.net/jython/?rev=5065&view=rev Author: nriley Date: 2008-08-03 07:42:24 +0000 (Sun, 03 Aug 2008) Log Message: ----------- Fix mistaken assumption that 'r+' will create a file. Modified Paths: -------------- branches/asm/Lib/os.py Modified: branches/asm/Lib/os.py =================================================================== --- branches/asm/Lib/os.py 2008-08-03 05:11:47 UTC (rev 5064) +++ branches/asm/Lib/os.py 2008-08-03 07:42:24 UTC (rev 5065) @@ -581,9 +581,11 @@ if not creating and not path.exists(filename): raise OSError(errno.ENOENT, errno.strerror(errno.ENOENT), filename) - if not writing or updating: - # Default to reading - reading = True + if not writing: + if updating: + writing = True + else: + reading = True if truncating and not writing: # Explicitly truncate, writing will truncate anyway This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2008-08-03 05:11:54
|
Revision: 5064 http://jython.svn.sourceforge.net/jython/?rev=5064&view=rev Author: zyasoft Date: 2008-08-03 05:11:47 +0000 (Sun, 03 Aug 2008) Log Message: ----------- Basic cleanup so that test_socket is runnable under current testing. Modified Paths: -------------- branches/asm/Lib/test/test_socket.py Modified: branches/asm/Lib/test/test_socket.py =================================================================== --- branches/asm/Lib/test/test_socket.py 2008-08-03 04:49:27 UTC (rev 5063) +++ branches/asm/Lib/test/test_socket.py 2008-08-03 05:11:47 UTC (rev 5064) @@ -1,11 +1,9 @@ -from __future__ import nested_scopes - """ AMAK: 20050515: This module is the test_socket.py from cpython 2.4, ported to jython. """ import unittest -import test_support +from test import test_support import errno import Queue This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2008-08-03 04:49:29
|
Revision: 5063 http://jython.svn.sourceforge.net/jython/?rev=5063&view=rev Author: nriley Date: 2008-08-03 04:49:27 +0000 (Sun, 03 Aug 2008) Log Message: ----------- Don't create file opened with r+; better validate file modes (fixes test_mailbox). Modified Paths: -------------- branches/asm/src/org/python/core/io/FileIO.java Modified: branches/asm/src/org/python/core/io/FileIO.java =================================================================== --- branches/asm/src/org/python/core/io/FileIO.java 2008-08-03 04:47:37 UTC (rev 5062) +++ branches/asm/src/org/python/core/io/FileIO.java 2008-08-03 04:49:27 UTC (rev 5063) @@ -40,6 +40,9 @@ /** true if the file is in appending mode */ private boolean appending = false; + /** true if the file is opened for reading and writing */ + private boolean plus = false; + /** * Construct a FileIO instance for the specified file name. * @@ -56,13 +59,17 @@ File fullPath = new RelativeFile(name); String rafMode = "r" + (writable ? "w" : ""); try { + if (plus && mode.charAt(0) == 'r' && !fullPath.isFile()) { + writable = false; + throw new FileNotFoundException(""); + } file = new RandomAccessFile(fullPath, rafMode); fileChannel = file.getChannel(); } catch (FileNotFoundException fnfe) { if (fullPath.isDirectory()) { throw Py.IOError(errno.EISDIR, "Is a directory"); } - if ( (rafMode.equals("rw") && !fullPath.canWrite()) || + if ( (writable && !fullPath.canWrite()) || fnfe.getMessage().endsWith("(Permission denied)")) { throw Py.IOError(errno.EACCES, "Permission denied: '" + name + "'"); } @@ -99,30 +106,29 @@ */ private void parseMode(String mode) { boolean rwa = false; - boolean plus = false; for (int i = 0; i < mode.length(); i++) { switch (mode.charAt(i)) { case 'r': - if (rwa) { + if (plus || rwa) { badMode(); } readable = rwa = true; break; case 'w': - if (rwa) { + if (plus || rwa) { badMode(); } writable = rwa = true; break; case 'a': - if (rwa) { + if (plus || rwa) { badMode(); } appending = writable = rwa = true; break; case '+': - if (plus) { + if (plus || !rwa) { badMode(); } readable = writable = plus = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2008-08-03 04:47:41
|
Revision: 5062 http://jython.svn.sourceforge.net/jython/?rev=5062&view=rev Author: nriley Date: 2008-08-03 04:47:37 +0000 (Sun, 03 Aug 2008) Log Message: ----------- Support setting atime from os.utime. Modified Paths: -------------- branches/asm/Lib/os.py Modified: branches/asm/Lib/os.py =================================================================== --- branches/asm/Lib/os.py 2008-08-03 04:45:39 UTC (rev 5061) +++ branches/asm/Lib/os.py 2008-08-03 04:47:37 UTC (rev 5062) @@ -499,23 +499,23 @@ """utime(path, (atime, mtime)) utime(path, None) - Set the access and modified time of the file to the given values. - If the second form is used, set the access and modified times to the + Set the access and modification time of the file to the given values. + If the second form is used, set the access and modification times to the current time. - Due to java limitations only the modification time is changed. + Due to Java limitations, on some platforms only the modification time + may be changed. """ - if times is not None: - # We don't use the access time, but typecheck it anyway - long(times[0]) - mtime = times[1] - else: - mtime = time.time() if path is None: raise TypeError('path must be specified, not None') - # Only the modification time is changed - File(sys.getPath(path)).setLastModified(long(mtime * 1000.0)) + if times is not None: + atime, mtime = times + else: + atime = mtime = time.time() + + _posix.utimes(path, long(atime * 1000), long(mtime * 1000)) + def close(fd): """close(fd) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2008-08-03 04:45:41
|
Revision: 5061 http://jython.svn.sourceforge.net/jython/?rev=5061&view=rev Author: zyasoft Date: 2008-08-03 04:45:39 +0000 (Sun, 03 Aug 2008) Log Message: ----------- Allow typecodes of B, H, I to fully use their storage. Don't run test_byteswap for u (Unicode) because it doesn't make sense given UTF-16 decoding. Fixes test_array. Modified Paths: -------------- branches/asm/Lib/test/test_array.py branches/asm/src/org/python/core/PyArray.java Modified: branches/asm/Lib/test/test_array.py =================================================================== --- branches/asm/Lib/test/test_array.py 2008-08-03 04:45:30 UTC (rev 5060) +++ branches/asm/Lib/test/test_array.py 2008-08-03 04:45:39 UTC (rev 5061) @@ -74,6 +74,10 @@ self.assertEqual(bi[1], len(a)) def test_byteswap(self): + if test_support.is_jython and self.typecode == 'u': + # Jython unicodes are already decoded from utf16, + # so this doesn't make sense + return a = array.array(self.typecode, self.example) self.assertRaises(TypeError, a.byteswap, 42) if a.itemsize in (1, 2, 4, 8): @@ -912,11 +916,12 @@ lower = 0 itemsize = a.itemsize if test_support.is_jython: - # XXX: unsigned itemsizes are larger than would be expected - # in CPython - itemsize /= 2 - #upper = long(pow(2, a.itemsize * 8)) - 1L - upper = long(pow(2, itemsize * 8)) - 1L + # unsigned itemsizes are larger than would be expected + # in CPython because Jython promotes to the next size + # (Java has no unsiged integers except for char) + upper = long(pow(2, a.itemsize * 8 - 1)) - 1L + else: + upper = long(pow(2, a.itemsize * 8)) - 1L self.check_overflow(lower, upper) Modified: branches/asm/src/org/python/core/PyArray.java =================================================================== --- branches/asm/src/org/python/core/PyArray.java 2008-08-03 04:45:30 UTC (rev 5060) +++ branches/asm/src/org/python/core/PyArray.java 2008-08-03 04:45:39 UTC (rev 5061) @@ -1327,7 +1327,6 @@ return; } - // check for overflow of the integral types if(type == Byte.TYPE) { long val; try { @@ -1337,7 +1336,7 @@ } if(val < (isSigned() ? 0 : Byte.MIN_VALUE)) { throw Py.OverflowError("value too small for " + type.getName()); - } else if(val > (isSigned() ? Byte.MAX_VALUE * 2 + 1 : Byte.MAX_VALUE)) { + } else if(val > Byte.MAX_VALUE) { throw Py.OverflowError("value too large for " + type.getName()); } } else if(type == Short.TYPE) { @@ -1349,7 +1348,7 @@ } if(val < (isSigned() ? 0 : Short.MIN_VALUE)) { throw Py.OverflowError("value too small for " + type.getName()); - } else if(val > (isSigned() ? Byte.MAX_VALUE * 2 + 1 : Short.MAX_VALUE)) { + } else if(val > Short.MAX_VALUE) { throw Py.OverflowError("value too large for " + type.getName()); } } else if(type == Integer.TYPE) { @@ -1361,7 +1360,7 @@ } if(val < (isSigned() ? 0 : Integer.MIN_VALUE)) { throw Py.OverflowError("value too small for " + type.getName()); - } else if(val > (isSigned() ? Short.MAX_VALUE * 2 + 1 : Integer.MAX_VALUE)) { + } else if(val > Integer.MAX_VALUE) { throw Py.OverflowError("value too large for " + type.getName()); } } else if(type == Long.TYPE) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2008-08-03 04:45:33
|
Revision: 5060 http://jython.svn.sourceforge.net/jython/?rev=5060&view=rev Author: nriley Date: 2008-08-03 04:45:30 +0000 (Sun, 03 Aug 2008) Log Message: ----------- jna-posix from http://svn.codehaus.org/jruby-contrib/trunk/jna-posix r213 + patch in http://jira.codehaus.org/browse/JRUBY-2885 for isatty on Windows + patch in http://jira.codehaus.org/browse/JRUBY-2887 for atime setting Modified Paths: -------------- branches/asm/extlibs/jna-posix.jar This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2008-08-03 04:33:41
|
Revision: 5059 http://jython.svn.sourceforge.net/jython/?rev=5059&view=rev Author: nriley Date: 2008-08-03 04:33:38 +0000 (Sun, 03 Aug 2008) Log Message: ----------- Remove workaround for issue 1059 (was fixed in r4713). Modified Paths: -------------- branches/asm/Lib/os.py Modified: branches/asm/Lib/os.py =================================================================== --- branches/asm/Lib/os.py 2008-08-03 03:09:49 UTC (rev 5058) +++ branches/asm/Lib/os.py 2008-08-03 04:33:38 UTC (rev 5059) @@ -508,9 +508,6 @@ if times is not None: # We don't use the access time, but typecheck it anyway long(times[0]) - if times[0] is None: # XXX http://bugs.jython.org/issue1059 - # CPython says the same, although it takes floats too - raise TypeError('an integer is required') mtime = times[1] else: mtime = time.time() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2008-08-03 03:09:51
|
Revision: 5058 http://jython.svn.sourceforge.net/jython/?rev=5058&view=rev Author: zyasoft Date: 2008-08-03 03:09:49 +0000 (Sun, 03 Aug 2008) Log Message: ----------- Unicode arrays -- array.array('u') -- now work as expected, by special casing the fact that we are storing them as an array of codepoints (ints). Because of this, byteswap doesn't make sense. Modified Paths: -------------- branches/asm/src/org/python/core/PyArray.java branches/asm/src/org/python/core/PyUnicode.java Modified: branches/asm/src/org/python/core/PyArray.java =================================================================== --- branches/asm/src/org/python/core/PyArray.java 2008-08-03 02:13:36 UTC (rev 5057) +++ branches/asm/src/org/python/core/PyArray.java 2008-08-03 03:09:49 UTC (rev 5058) @@ -119,8 +119,13 @@ self.fromlist(initial); } else if (initial instanceof PyString && !(initial instanceof PyUnicode)) { self.fromstring(initial.toString()); - } else if (initial instanceof PyUnicode && "u".equals(typecode)) { - self.fromunicode(initial.toString()); + } else if ("u".equals(typecode)) { + if (initial instanceof PyUnicode) { + self.extendArray(((PyUnicode) initial).toCodePoints()); + } + else { + self.extendUnicodeIter(initial); + } } else { self.extendInternal(initial); } @@ -376,6 +381,8 @@ String value; if ("c".equals(typecode)) { value = PyString.encode_UnicodeEscape(tostring(), true); + } else if ("u".equals(typecode)) { + value = (new PyUnicode(tounicode())).__repr__().toString(); } else { value = tolist().toString(); } @@ -408,28 +415,68 @@ append(value); } + private static int getCodePoint(PyObject obj) { + if (obj instanceof PyUnicode) { + PyUnicode u = (PyUnicode) obj; + int[] codepoints = u.toCodePoints(); + if (codepoints.length == 1) { + return codepoints[0]; + } + } + throw Py.TypeError("array item must be unicode character"); + } + + + // relax to allow mixing with PyString, integers + private static int getCodePointOrInt(PyObject obj) { + if (obj instanceof PyUnicode) { + PyUnicode u = (PyUnicode) obj; + return u.toCodePoints()[0]; + } + else if (obj instanceof PyString) { + PyString s = (PyString) obj; + return s.toString().charAt(0); + } + else if (obj.__nonzero__()) { + return ((PyInteger)obj.__int__()).getValue(); + } + else { + return -1; + } + } + /** * Append new value x to the end of the array. * * @param value * item to be appended to the array */ + public void append(PyObject value) { // Currently, this is asymmetric with extend, which // *will* do conversions like append(5.0) to an int array. // Also, cpython 2.2 will do the append coersion. However, // it is deprecated in cpython 2.3, so maybe we are just // ahead of our time ;-) + int afterLast = delegate.getSize(); - delegate.makeInsertSpace(afterLast); - try { - set(afterLast, value); - } catch(PyException e) { - delegate.setSize(afterLast); - throw new PyException(e.type, e.value); + if ("u".equals(typecode)) { + int codepoint = getCodePoint(value); + delegate.makeInsertSpace(afterLast); + Array.setInt(data, afterLast, codepoint); + } else { + + delegate.makeInsertSpace(afterLast); + try { + set(afterLast, value); + } catch (PyException e) { + delegate.setSize(afterLast); + throw new PyException(e.type, e.value); + } } } + @ExposedMethod public void array_byteswap() { byteswap(); @@ -442,7 +489,7 @@ * written on a machine with a different byte order. */ public void byteswap() { - if (getItemsize() == 0) { + if (getItemsize() == 0 || "u".equals(typecode)) { throw Py.RuntimeError("don't know how to byteswap this array type"); } ByteSwapper.swap(data); @@ -567,13 +614,24 @@ public final int array_count(PyObject value) { // note: cpython does not raise type errors based on item type; int iCount = 0; - for(int i = 0; i < delegate.getSize(); i++) { - if(value.equals(Py.java2py(Array.get(data, i)))) - iCount++; + int len = delegate.getSize(); + if ("u".equals(typecode)) { + int codepoint = getCodePointOrInt(value); + for (int i = 0; i < len; i++) { + if (codepoint == Array.getInt(data, i)) { + iCount++; + } + } + } else { + + for (int i = 0; i < len; i++) { + if (value.equals(Py.java2py(Array.get(data, i)))) { + iCount++; + } + } } return iCount; } - /** * Return the number of occurrences of x in the array. * @@ -654,13 +712,20 @@ * object of type PyString, PyArray or any object that can be * iterated over. */ + private void extendInternal(PyObject iterable) { - // string input - if (iterable instanceof PyString) { - fromstring(((PyString)iterable).toString()); - // PyArray input + if (iterable instanceof PyUnicode) { + if ("u".equals(typecode)) { + extendUnicodeIter(iterable); + } else if ("c".equals(typecode)){ + throw Py.TypeError("array item must be char"); + } else { + throw Py.TypeError("an integer is required"); + } + } else if (iterable instanceof PyString) { + fromstring(((PyString) iterable).toString()); } else if (iterable instanceof PyArray) { - PyArray source = (PyArray)iterable; + PyArray source = (PyArray) iterable; if (!source.typecode.equals(typecode)) { throw Py.TypeError("can only extend with array of same kind"); } @@ -693,7 +758,32 @@ } } } + + private void extendUnicodeIter(PyObject iterable) { + for (PyObject item : iterable.asIterable()) { + PyUnicode uitem; + try { + uitem = (PyUnicode) item; + } catch (ClassCastException e) { + throw Py.TypeError("Type not compatible with array type"); + } + for (int codepoint : uitem.toCodePoints()) { + int afterLast = delegate.getSize(); + delegate.makeInsertSpace(afterLast); + Array.setInt(data, afterLast, codepoint); + } + } + } + private void extendArray(int[] items) { + int last = delegate.getSize(); + delegate.ensureCapacity(last + items.length); + for (int item : items) { + Array.set(data, last++, item); + delegate.size++; + } + } + @ExposedMethod public final void array_fromfile(PyObject f, int count){ fromfile(f, count); @@ -883,16 +973,16 @@ } } - public void fromunicode(String input) { + public void fromunicode(PyUnicode input) { array_fromunicode(input); } @ExposedMethod - final void array_fromunicode(String input) { + final void array_fromunicode(PyUnicode input) { if (!"u".equals(typecode)) { throw Py.ValueError("fromunicode() may only be called on type 'u' arrays"); } - array_fromstring(input); + extend(input); } /** @@ -902,6 +992,9 @@ * index of the item to be retrieved from the array */ protected PyObject pyget(int i) { + if ("u".equals(typecode)) { + return new PyUnicode(Array.getInt(data, i)); + } return Py.java2py(Array.get(data, i)); } @@ -1067,10 +1160,21 @@ */ private int indexInternal(PyObject value) { // note: cpython does not raise type errors based on item type - for(int i = 0; i < delegate.getSize(); i++) { - if(value.equals(Py.java2py(Array.get(data, i)))) { - return i; + + int len = delegate.getSize(); + if ("u".equals(typecode)) { + int codepoint = getCodePointOrInt(value); + for (int i = 0; i < len; i++) { + if (codepoint == Array.getInt(data, i)) { + return i; + } } + } else { + for (int i = 0; i < len; i++) { + if (value.equals(Py.java2py(Array.get(data, i)))) { + return i; + } + } } return -1; } @@ -1092,13 +1196,24 @@ */ public void insert(int index, PyObject value) { index = calculateIndex(index); - delegate.makeInsertSpace(index); - Array.set(data, index, Py.tojava(value, type)); + if ("u".equals(typecode)) { + int codepoint = getCodePoint(value); + delegate.makeInsertSpace(index); + Array.setInt(data, index, codepoint); + + } else { + delegate.makeInsertSpace(index); + Array.set(data, index, Py.tojava(value, type)); + } } @ExposedMethod(defaults="-1") public final PyObject array_pop(int i){ - return pop(i); + PyObject val = pop(i); + if ("u".equals(typecode)) { + return new PyUnicode(val.asInt()); + } + return val; } /** @@ -1207,6 +1322,11 @@ * value to set the element to */ public void set(int i, PyObject value) { + if ("u".equals(typecode)) { + Array.setInt(data, i, getCodePoint(value)); + return; + } + // check for overflow of the integral types if(type == Byte.TYPE) { long val; @@ -1387,8 +1507,15 @@ */ public PyObject tolist() { PyList list = new PyList(); - for(int i = 0; i < delegate.getSize(); i++) { - list.append(Py.java2py(Array.get(data, i))); + int len = delegate.getSize(); + if ("u".equals(typecode)) { + for (int i = 0; i < len; i++) { + list.append(new PyUnicode(Array.getInt(data, i))); + } + } else { + for (int i = 0; i < len; i++) { + list.append(Py.java2py(Array.get(data, i))); + } } return list; } @@ -1456,13 +1583,22 @@ return StringUtil.fromBytes(bos.toByteArray()); } - @ExposedMethod - public final PyObject array_tounicode() { + public String tounicode() { if (!"u".equals(typecode)) { throw Py.ValueError("tounicode() may only be called on type 'u' arrays"); } - return new PyUnicode(tostring()); + int len = delegate.getSize(); + int[] codepoints = new int[len]; + for(int i = 0; i < len; i++) + codepoints[i] = Array.getInt(data, i); + return new String(codepoints, 0, codepoints.length); } + + + @ExposedMethod + public final PyObject array_tounicode() { + return new PyUnicode(tounicode()); + } // PyArray can't extend anymore, so delegate private class ArrayDelegate extends AbstractArray { Modified: branches/asm/src/org/python/core/PyUnicode.java =================================================================== --- branches/asm/src/org/python/core/PyUnicode.java 2008-08-03 02:13:36 UTC (rev 5057) +++ branches/asm/src/org/python/core/PyUnicode.java 2008-08-03 03:09:49 UTC (rev 5058) @@ -62,6 +62,10 @@ this(TYPE, new String(new int[]{codepoint}, 0, 1)); } + public PyUnicode(int[] codepoints) { + this(new String(codepoints, 0, codepoints.length)); + } + PyUnicode(StringBuilder buffer) { this(TYPE, new String(buffer)); } @@ -73,7 +77,7 @@ } return buffer; } - + PyUnicode(Iterator<Integer> iter) { this(fromCodePoints(iter)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-08-03 02:13:39
|
Revision: 5057 http://jython.svn.sourceforge.net/jython/?rev=5057&view=rev Author: pjenvey Date: 2008-08-03 02:13:36 +0000 (Sun, 03 Aug 2008) Log Message: ----------- o pre and xreadlines were removed in CPython 2.4 o include some other modules I hope actually work Modified Paths: -------------- branches/asm/CPythonLib.includes branches/asm/Lib/test/regrtest.py branches/asm/src/org/python/modules/Setup.java Removed Paths: ------------- branches/asm/src/org/python/modules/xreadlines.java Modified: branches/asm/CPythonLib.includes =================================================================== --- branches/asm/CPythonLib.includes 2008-08-02 21:43:22 UTC (rev 5056) +++ branches/asm/CPythonLib.includes 2008-08-03 02:13:36 UTC (rev 5057) @@ -47,6 +47,7 @@ dircache.py dircmp.py dis.py +DocXMLRPCServer.py dospath.py dumbdbm.py exceptions.py @@ -117,6 +118,7 @@ repr.py rfc822.py rlcompleter.py +robotparser.py runpy.py sched.py sha.py @@ -137,6 +139,7 @@ string.py StringIO.py symbol.py +tabnanny.py this.py threading.py textwrap.py Modified: branches/asm/Lib/test/regrtest.py =================================================================== --- branches/asm/Lib/test/regrtest.py 2008-08-02 21:43:22 UTC (rev 5056) +++ branches/asm/Lib/test/regrtest.py 2008-08-03 02:13:36 UTC (rev 5057) @@ -1432,7 +1432,6 @@ test_pyexpat test_resource test_rgbimg - test_robotparser test_rotor test_scriptpackages test_signal Modified: branches/asm/src/org/python/modules/Setup.java =================================================================== --- branches/asm/src/org/python/modules/Setup.java 2008-08-02 21:43:22 UTC (rev 5056) +++ branches/asm/src/org/python/modules/Setup.java 2008-08-03 02:13:36 UTC (rev 5057) @@ -31,7 +31,6 @@ "operator", "time:org.python.modules.time.Time", "_py_compile", - "pre:org.python.modules.re", "_sre", "synchronize", "cPickle", @@ -45,7 +44,6 @@ "_jython", "_new:org.python.modules._newmodule", "_weakref:org.python.modules._weakref.WeakrefModule", - "xreadlines", "errno", "array:org.python.modules.ArrayModule", "_random:org.python.modules.random.RandomModule", Deleted: branches/asm/src/org/python/modules/xreadlines.java =================================================================== --- branches/asm/src/org/python/modules/xreadlines.java 2008-08-02 21:43:22 UTC (rev 5056) +++ branches/asm/src/org/python/modules/xreadlines.java 2008-08-03 02:13:36 UTC (rev 5057) @@ -1,59 +0,0 @@ -// Copyright (c) 2001 Finn Bock. - -package org.python.modules; - -import org.python.core.*; - -public class xreadlines { - private final static int CHUNKSIZE = 8192; - - public static PyString __doc__xreadlines = new PyString( - "xreadlines(f)\n" + - "\n" + - "Return an xreadlines object for the file f." - ); - - public static PyObject xreadlines$(PyObject file) { - return new XReadlineObj(file); - } - - public static class XReadlineObj extends PyObject { - private PyObject file; - private PyObject lines = null; - private int lineslen = 0; - private int lineno = 0; - private int abslineno = 0; - - public XReadlineObj(PyObject file) { - this.file = file; - } - - public PyObject __iter__() { - return new PySequenceIter(this); - } - - public PyObject __finditem__(PyObject idx) { - return __finditem__(((PyInteger)idx.__int__()).getValue()); - } - - public PyObject __finditem__(int idx) { - if (idx != abslineno) { - throw Py.RuntimeError( - "xreadlines object accessed out of order"); - } - - if (lineno >= lineslen) { - lines = file.invoke("readlines", Py.newInteger(CHUNKSIZE)); - lineno = 0; - lineslen = lines.__len__(); - } - abslineno++; - return lines.__finditem__(lineno++); - } - - public String toString() { - return "<xreadlines object " + Py.idstr(this) + ">"; - } - - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2008-08-02 21:43:29
|
Revision: 5056 http://jython.svn.sourceforge.net/jython/?rev=5056&view=rev Author: zyasoft Date: 2008-08-02 21:43:22 +0000 (Sat, 02 Aug 2008) Log Message: ----------- Fixed roundtripping so that eval(str(a)) == a where a uses a typecode of a Java object, along with other similar minor issues. Rewrote test_array_jy to use unittest, and removed testing now being done by standard 2.5 test_array Modified Paths: -------------- branches/asm/Lib/test/test_array_jy.py branches/asm/src/org/python/core/PyArray.java branches/asm/src/org/python/modules/ArrayModule.java Removed Paths: ------------- branches/asm/Lib/test/output/test_array_jy Deleted: branches/asm/Lib/test/output/test_array_jy =================================================================== --- branches/asm/Lib/test/output/test_array_jy 2008-08-02 21:40:59 UTC (rev 5055) +++ branches/asm/Lib/test/output/test_array_jy 2008-08-02 21:43:22 UTC (rev 5056) @@ -1,4 +0,0 @@ -test_array -array module (test_array.py) -array -zeros Modified: branches/asm/Lib/test/test_array_jy.py =================================================================== --- branches/asm/Lib/test/test_array_jy.py 2008-08-02 21:40:59 UTC (rev 5055) +++ branches/asm/Lib/test/test_array_jy.py 2008-08-02 21:43:22 UTC (rev 5056) @@ -1,438 +1,51 @@ -# CAU: Adaptation of the cpython 2.2 test_array.py for jython 2.2 -# Formerly test_jarray.py, now test_array.py so that this -# test completely supercedes the cpthyhon test. It would -# be better to simply complement the cpython test, but that -# test bombs out too early due to basic incompatibilities. -# -# The jarray module is being phased out, with all functionality -# now available in the array module. +# The jarray module is being phased out, with all functionality +# now available in the array module. -from test_support import * +import unittest +from test import test_support from array import array, zeros -import sys from java.lang import String from java.lang.reflect import Array from java.util import Arrays -print 'array module (test_array.py)' +class ArrayJyTestCase(unittest.TestCase): -def main(): - - test_jarray() # while it's still supported - - test_java_compat() - test_java_object_arrays() + def test_jarray(self): # until it is fully formally removed - testtype('c', 'c') - for type in (['b', 'h', 'i', 'l', 'f', 'd']): - testtype(type, 1) - - #test a mix of known success and failure cases - init_tests() - extend_tests() - fromlist_tests() + # While jarray is still being phased out, just flex the initilaizers. + # The rest of the test for array will catch all the big problems. + import jarray + jarray.array(range(5), 'i') + jarray.array([String("a"), String("b"), String("c")], String) + jarray.zeros(5, 'i') + jarray.zeros(5, String) - unlink(TESTFN) + def test_java_object_arrays(self): + jStringArr = array(String, [String("a"), String("b"), String("c")]) + self.assert_( + Arrays.equals(jStringArr.typecode, str(String)), + "String array typecode of wrong type, expected %s, found %s" % + (jStringArr.typecode, str(String))) + self.assertEqual(zeros(String, 5), Array.newInstance(String, 5)) -def test_jarray(): # until it is fully formally removed + import java # require for eval to work + self.assertEqual(jStringArr, eval(str(jStringArr))) - # While jarray is still being phased out, just flex the initilaizers. - # The rest of the test for array will catch all the big problems. - import jarray - jarray.array(range(5), 'i') - jarray.array([String("a"), String("b"), String("c")], String) - jarray.zeros(5, 'i') - jarray.zeros(5, String) + def test_java_compat(self): + from java import awt + hsb = awt.Color.RGBtoHSB(0,255,255, None) + self.assertEqual(hsb, array('f', [0.5,1,1]), + "output hsb float array does not correspond to input rgb values") + rgb = apply(awt.Color.HSBtoRGB, tuple(hsb)) + self.assertEqual(rgb, -0xff0001, + "output rgb bytes don't match input hsb floats") + hsb1 = zeros('f', 3) + awt.Color.RGBtoHSB(0,255,255, hsb1) + self.assertEqual(hsb, hsb1, "hsb float arrays were not equal") -def test_java_object_arrays(): - jStringArr = array(String, [String("a"), String("b"), String("c")]) - verify(Arrays.equals(jStringArr.typecode, str(String)), - "String array typecode of wrong type, expected %s, found %s" % - (jStringArr.typecode, str(String))) - verify(zeros(String, 5) == Array.newInstance(String, 5)) +def test_main(): + test_support.run_unittest(ArrayJyTestCase) - import java # require for eval to work - if jStringArr != eval(str(jStringArr)): - raise TestFailed, "eval(str(%s)) <> %s" % (jStringArr,)*2 - - -def test_java_compat(): - print 'array' - from java import awt - hsb = awt.Color.RGBtoHSB(0,255,255, None) - #print hsb - verify(hsb == array('f', [0.5,1,1]), - "output hsb float array does not correspond to input rgb values") - - rgb = apply(awt.Color.HSBtoRGB, tuple(hsb)) - #print hex(rgb) - verify(rgb == 0xff00ffff, "output rgb bytes don't match input hsb floats") - - print 'zeros' - hsb1 = zeros('f', 3) - awt.Color.RGBtoHSB(0,255,255, hsb1) - #print hsb, hsb1 - verify(hsb == hsb1, "hsb float arrays were not equal") - -def testoverflow(type, lowerLimit, upperLimit): - # should not overflow assigning lower limit - if verbose: - print "test overflow: array(%s, [%s])" % (lowerLimit, type) - try: - a = array(type, [lowerLimit]) - except: - raise TestFailed("array(%s) overflowed assigning %s" % - (lowerLimit, type)) - # should overflow assigning less than lower limit - if verbose: - print "test overflow: array(%s, [%s])" % (lowerLimit-1, type) - try: - a = array(type, [lowerLimit-1]) - raise TestFailed, "array(%s) did not overflow assigning %s" %\ - (lowerLimit-1, type) - except OverflowError: - pass - # should not overflow assigning upper limit - if verbose: - print "test verflow: array(%s, [%s])" % (upperLimit, type) - try: - a = array(type, [upperLimit]) - except: - raise TestFailed, "array(%s) overflowed assigning %s" %\ - (upperLimit, type) - # should overflow assigning more than upper limit - if verbose: - print "test overflow: array(%s, [%s])" % (upperLimit+1, type) - try: - a = array(type, [upperLimit+1]) - raise TestFailed, "array(%s) did not overflow assigning %s" %\ - (upperLimit+1, type) - except OverflowError: - pass - - -def testtype(type, example): - - if verbose: - print "testing type ", type - - a = array(type) - a.append(example) - if verbose: - print 40*'*' - print 'array after append: ', a - a.typecode - a.itemsize - - if a <> eval(str(a)): - raise TestFailed, "eval(str(%s)) <> %s" % (a,a) - - if a.typecode in ('i', 'b', 'h', 'l'): - a.byteswap() - - if a.typecode == 'c': - f = open(TESTFN, "w") - f.write("The quick brown fox jumps over the lazy dog.\n") - f.close() - f = open(TESTFN, 'r') - a.fromfile(f, 10) - f.close() - if verbose: - print 'char array with 10 bytes of TESTFN appended: ', a - a.fromlist(['a', 'b', 'c']) - if verbose: - print 'char array with list appended: ', a - - a.insert(0, example) - if verbose: - print 'array of %s after inserting another:' % a.typecode, a - f = open(TESTFN, 'w') - a.tofile(f) - f.close() - - # This block is just to verify that the operations don't blow up. - a.tolist() - a.tostring() - repr(a) - str(a) - - if verbose: - print 'array of %s converted to a list: ' % a.typecode, a.tolist() - if verbose: - print 'array of %s converted to a string: ' \ - % a.typecode, a.tostring() - - if type == 'c': - a = array(type, "abcde") - a[:-1] = a - if a != array(type, "abcdee"): - raise TestFailed, "array(%s) self-slice-assign (head)" % type - a = array(type, "abcde") - a[1:] = a - if a != array(type, "aabcde"): - raise TestFailed, "array(%s) self-slice-assign (tail)" % type - a = array(type, "abcde") - a[1:-1] = a - if a != array(type, "aabcdee"): - raise TestFailed, "array(%s) self-slice-assign (cntr)" % type - if a.index("e") != 5: - raise TestFailed, "array(%s) index-test" % type - if a.count("a") != 2: - raise TestFailed, "array(%s) count-test" % type - a.remove("e") - if a != array(type, "aabcde"): - raise TestFailed, "array(%s) remove-test" % type - if a.pop(0) != "a": - raise TestFailed, "array(%s) pop-test" % type - if a.pop(1) != "b": - raise TestFailed, "array(%s) pop-test" % type - a.extend(array(type, "xyz")) - if a != array(type, "acdexyz"): - raise TestFailed, "array(%s) extend-test" % type - a.pop() - a.pop() - a.pop() - x = a.pop() - if x != 'e': - raise TestFailed, "array(%s) pop-test" % type - if a != array(type, "acd"): - raise TestFailed, "array(%s) pop-test" % type - a.reverse() - if a != array(type, "dca"): - raise TestFailed, "array(%s) reverse-test" % type - else: - a = array(type, [1, 2, 3, 4, 5]) - a[:-1] = a - if a != array(type, [1, 2, 3, 4, 5, 5]): - raise TestFailed, "array(%s) self-slice-assign (head)" % type - a = array(type, [1, 2, 3, 4, 5]) - a[1:] = a - if a != array(type, [1, 1, 2, 3, 4, 5]): - raise TestFailed, "array(%s) self-slice-assign (tail)" % type - a = array(type, [1, 2, 3, 4, 5]) - a[1:-1] = a - if a != array(type, [1, 1, 2, 3, 4, 5, 5]): - raise TestFailed, "array(%s) self-slice-assign (cntr)" % type - if a.index(5) != 5: - raise TestFailed, "array(%s) index-test" % type - if a.count(1) != 2: - raise TestFailed, "array(%s) count-test" % type - a.remove(5) - if a != array(type, [1, 1, 2, 3, 4, 5]): - raise TestFailed, "array(%s) remove-test" % type - if a.pop(0) != 1: - raise TestFailed, "array(%s) pop-test" % type - if a.pop(1) != 2: - raise TestFailed, "array(%s) pop-test" % type - a.extend(array(type, [7, 8, 9])) - if a != array(type, [1, 3, 4, 5, 7, 8, 9]): - raise TestFailed, "array(%s) extend-test" % type - a.pop() - a.pop() - a.pop() - x = a.pop() - if x != 5: - raise TestFailed, "array(%s) pop-test" % type - if a != array(type, [1, 3, 4]): - raise TestFailed, "array(%s) pop-test" % type - a.reverse() - if a != array(type, [4, 3, 1]): - raise TestFailed, "array(%s) reverse-test" % type - - # test that overflow exceptions are raised as expected for assignment - # to array of specific integral types - from math import pow - - #check using long inputs - if type in ('b', 'h', 'i', 'l'): - a = array(type) - signedLowerLimit = -1 * long(pow(2, a.itemsize * 8 - 1)) - signedUpperLimit = long(pow(2, a.itemsize * 8 - 1)) - 1L - unsignedLowerLimit = 0 - unsignedUpperLimit = long(pow(2, a.itemsize * 8)) - 1L - testoverflow(type, signedLowerLimit, signedUpperLimit) - - #check using integer inputs - int cannot hold MAXINT+1 nor MININT-1 - # so only valid test types are byte and short for this test - if type in ('b', 'h'): - a = array(type) - signedLowerLimit = -1 * int(pow(2, a.itemsize * 8 - 1)) - signedUpperLimit = int(pow(2, a.itemsize * 8 - 1)) - 1 - unsignedLowerLimit = 0 - unsignedUpperLimit = int(pow(2, a.itemsize * 8)) - 1 - testoverflow(type, signedLowerLimit, signedUpperLimit) - - -def init_tests(): - test = array('c', ['t','e','s','t']) - verify(init_test( "test: String initialisation", "test", 'c') == test, - "string initialisation failed") - - test = array('i', [41,42,43,44]) - s = test.tostring(); - verify(init_test( "test: String2 initialisation", s, 'i') == test, - "string 2 initialisation failed") - - init_test( "test: List initialisation", [1,2,3,4], 'i') - - init_test( "test: Tuple initialisation", (1,2,3,4), 'i') - - test = array('i', [1,2,3,4]) - verify(init_test( "test: array initialisation", test, 'i') == test, - "array init failed") - - try: - init_test('test: "broken" list initialisation', [1,2,3,4, 'fred'], 'i') - raise TestFailed, '"broken" list initialisation' - except TypeError: - pass - - test = array('i', [1,2,3,4]) - try: - init_test('test: "broken" PyArray initialisation', test, 'd') - raise TestFailed, '"broken" PyArray initialisation' - except TypeError: - pass - - f = open(TESTFN, "w") - #f.write("\x00\x00\x00\x01") - f.write("test message\nline2\nline3"); - f.close(); - - f = open(TESTFN, "r") - try: - init_test( "test: Invalid initialisation object (file)", f, 'i') - raise TestFailed, "Invalid initialisation object (file)" - except TypeError: - pass - f.close() - - try: - init_test( "test: Invalid initialisation object (module)", sys, 'i') - raise TestFailed, "Invalid initialisation object (module)" - except TypeError: - pass - -def extend_tests(): - test = array('c', 'testextend') - verify(extend_test("test: String extend", "test", "extend", 'c') == test, - "String extend failed") - - test = array('i', [1,2,3,4,51,52,53,54]); - verify( extend_test("test: List extend", [1,2,3,4], [51,52,53,54], 'i') == test, - "List extend failed") - - test = array('i', (1,2,3,4,51,52,53,54)); - verify( extend_test("test: Tuple extend", (1,2,3,4), (51,52,53,54), 'i') == test, - "Tuple extend failed") - - try: - extend_test('test: "broken" list extend', [1,2,3,4], [51,52,53,"fred"], 'i') - raise TestFailed, 'test: "broken" list extend' - except TypeError: - pass - - a = array('d', [123.45, 567.89]) - test = array('i', [1,2,3,4]) - try: - assert extend_test("test: Array type mismatch", [1,2,3,4], a, 'i') == test, \ - "Array mismatch test failed" - raise TestFailed, "test: Array type mismatch" - except TypeError: - pass - del a - - f = open(TESTFN, "r") - try: - extend_test("test: incorrect type extend (file)", [1,2,3,4], f, 'i') - raise TestFailed, "test: incorrect type extend (file)" - except TypeError: - pass - f.close() - - try: - extend_test("test: incorrect type extend (module)", (1,2,3,4), sys, 'i') - raise TestFailed, "test: incorrect type extend (module)" - except TypeError: - pass - - try: - extend_test("test: incorrect type extend (integer)", [], 456, 'i') - raise TestFailed, "test: incorrect type extend (integer)" - except TypeError: - pass - -def fromlist_tests(): - test = array('c', ['t','e','s','t','h','e','l','l','o']) - verify(fromlist_test("test: String fromlist", "test", ['h','e','l','l','o'], 'c') == test, - "String fromlist failed") - - test = array('i', [1,2,3,4,51,52,53,54]) - verify(fromlist_test("test: integer fromlist", [1,2,3,4], [51,52,53,54], 'i') == test, - "integer fromlist failed") - - try: - fromlist_test('test: "broken" fromlist (integer)', [1,2,3,4], [51,52,53,"fred"], 'i') - raise TestFailed, 'test: "broken" fromlist (integer)' - except TypeError: - pass - - try: - fromlist_test("test: invalid fromlist (tuple)", [1,2,3,4], (51,52,53,54), 'i') - raise TestFailed, "test: invalid fromlist (tuple)" - except TypeError: - pass - -def init_test(name, init, typecode): - if verbose: - print 40*'*' - print name, "- type:", typecode - print "initialiser:", init - - a = array(typecode, init) - - if verbose: - print a - - return a - -def extend_test(name, init, extend, typecode): - if verbose: - print 40*'*' - print name, "- type:", typecode - - a = array(typecode, init) - - if verbose: - print "initial:", a - print "extended by:", extend - - a.extend(extend) - - #if no exceptions then - if verbose: - print "final:", a - - return a - -def fromlist_test(name, init, listdata, typecode): - if verbose: - print 40*'*' - print name , "- type:", typecode - - a = array(typecode, init) - - if verbose: - print "initial:", a - print "fromlist source:", listdata - - a.fromlist(listdata) - - #if no exceptions then - if verbose: - print "final:", a - - return a - -main() +if __name__ == "__main__": + test_main() Modified: branches/asm/src/org/python/core/PyArray.java =================================================================== --- branches/asm/src/org/python/core/PyArray.java 2008-08-02 21:40:59 UTC (rev 5055) +++ branches/asm/src/org/python/core/PyArray.java 2008-08-02 21:43:22 UTC (rev 5056) @@ -371,17 +371,22 @@ @Override public String toString() { if (__len__() == 0) { - return String.format("array('%s')", typecode); + return String.format("array(%s)", encodeTypecode(typecode)); } String value; if ("c".equals(typecode)) { - value = tostring(); + value = PyString.encode_UnicodeEscape(tostring(), true); } else { value = tolist().toString(); } - return String.format("array('%s', %s)", typecode, value); + return String.format("array(%s, %s)", encodeTypecode(typecode), value); } + private String encodeTypecode(String typecode) { + if (typecode.length() > 1) return typecode; + else return "'" + typecode + "'"; + } + /** * * @param c Modified: branches/asm/src/org/python/modules/ArrayModule.java =================================================================== --- branches/asm/src/org/python/modules/ArrayModule.java 2008-08-02 21:40:59 UTC (rev 5055) +++ branches/asm/src/org/python/modules/ArrayModule.java 2008-08-02 21:43:22 UTC (rev 5056) @@ -24,13 +24,13 @@ " 'z' boolean 1 \n" + " 'c' character 1 \n" + " 'b' signed integer 1 \n" + - //" 'B' unsigned integer 1 \n" + + " 'B' unsigned integer 1 \n" + " 'h' signed integer 2 \n" + - //" 'H' unsigned integer 2 \n" + + " 'H' unsigned integer 2 \n" + " 'i' signed integer 2 \n" + - //" 'I' unsigned integer 2 \n" + + " 'I' unsigned integer 2 \n" + " 'l' signed integer 4 \n" + - //" 'L' unsigned integer 4 \n" + + " 'L' unsigned integer 4 \n" + " 'f' floating point 4 \n" + " 'd' floating point 8 \n" + "\n" + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2008-08-02 21:41:03
|
Revision: 5055 http://jython.svn.sourceforge.net/jython/?rev=5055&view=rev Author: zyasoft Date: 2008-08-02 21:40:59 +0000 (Sat, 02 Aug 2008) Log Message: ----------- threading does not maintain a dict of limbo threads, since this doesn't make sense in Jython. Remove code testing cleanup of threading._limbo in test_support.threading_setup/thread_cleanup Modified Paths: -------------- branches/asm/Lib/test/test_support.py Modified: branches/asm/Lib/test/test_support.py =================================================================== --- branches/asm/Lib/test/test_support.py 2008-08-02 21:35:23 UTC (rev 5054) +++ branches/asm/Lib/test/test_support.py 2008-08-02 21:40:59 UTC (rev 5055) @@ -536,7 +536,7 @@ def threading_setup(): import threading - return len(threading._active), len(threading._limbo) + return len(threading._active), 0 def threading_cleanup(num_active, num_limbo): import threading @@ -548,11 +548,6 @@ count += 1 time.sleep(0.1) - count = 0 - while len(threading._limbo) != num_limbo and count < _MAX_COUNT: - count += 1 - time.sleep(0.1) - def reap_children(): """Use this function at the end of test_main() whenever sub-processes are started. This will help ensure that no extra children (zombies) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2008-08-02 21:35:29
|
Revision: 5054 http://jython.svn.sourceforge.net/jython/?rev=5054&view=rev Author: zyasoft Date: 2008-08-02 21:35:23 +0000 (Sat, 02 Aug 2008) Log Message: ----------- Raise a ValueError if attempt to set thread.stack_size > 0 but < 32768. Fixes test_thread. Modified Paths: -------------- branches/asm/src/org/python/modules/thread/thread.java Modified: branches/asm/src/org/python/modules/thread/thread.java =================================================================== --- branches/asm/src/org/python/modules/thread/thread.java 2008-08-02 19:51:15 UTC (rev 5053) +++ branches/asm/src/org/python/modules/thread/thread.java 2008-08-02 21:35:23 UTC (rev 5054) @@ -69,7 +69,13 @@ return stack_size; case 1: long old_stack_size = stack_size; - stack_size = ((PyInteger)args[0].__int__()).getValue(); + int proposed_stack_size = ((PyInteger)args[0].__int__()).getValue(); + if (proposed_stack_size != 0 && proposed_stack_size < 32768) { + // as specified by Python, Java quietly ignores what + // it considers are too small + throw Py.ValueError("size not valid: " + proposed_stack_size + " bytes"); + } + stack_size = proposed_stack_size; return old_stack_size; default: throw Py.TypeError("stack_size() takes at most 1 argument (" + args.length + "given)"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-08-02 19:51:20
|
Revision: 5053 http://jython.svn.sourceforge.net/jython/?rev=5053&view=rev Author: pjenvey Date: 2008-08-02 19:51:15 +0000 (Sat, 02 Aug 2008) Log Message: ----------- switch some new style unary ops to throw TypeErrors instead of AttributeErrors when not implemented. the old styles still raise AttributeErrors (both styles now match CPython). we assume __len/int/long/float/complex__ raise AttributeErrors in many places so leaving them alone for now Modified Paths: -------------- branches/asm/Lib/test/test_descr_jy.py branches/asm/src/org/python/core/PyInstance.java branches/asm/src/org/python/core/PyObject.java branches/asm/src/org/python/core/__builtin__.java Modified: branches/asm/Lib/test/test_descr_jy.py =================================================================== --- branches/asm/Lib/test/test_descr_jy.py 2008-08-02 08:49:57 UTC (rev 5052) +++ branches/asm/Lib/test/test_descr_jy.py 2008-08-02 19:51:15 UTC (rev 5053) @@ -2,10 +2,21 @@ Made for Jython. """ -import test_support import types import unittest +from test import test_support +class Old: + pass + + +class New(object): + pass + + +old = Old() +new = New() + class TestDescrTestCase(unittest.TestCase): def test_class_dict_is_copy(self): @@ -255,10 +266,39 @@ self.assertEqual(foo, set([1])) +class DescrExceptionsTestCase(unittest.TestCase): + + def test_hex(self): + self._test(hex) + + def test_oct(self): + self._test(oct) + + def test_other(self): + for op in '-', '+', '~': + try: + eval('%s(old)' % op) + except AttributeError: + pass + else: + self._assert(False, 'Expected an AttributeError, op: %s' % op) + try: + eval('%s(new)' % op) + except TypeError: + pass + else: + self._assert(False, 'Expected a TypeError, op: %s' % op) + + def _test(self, func): + self.assertRaises(AttributeError, func, old) + self.assertRaises(TypeError, func, new) + + def test_main(): test_support.run_unittest(TestDescrTestCase, SubclassDescrTestCase, - InPlaceTestCase) + InPlaceTestCase, + DescrExceptionsTestCase) if __name__ == '__main__': test_main() Modified: branches/asm/src/org/python/core/PyInstance.java =================================================================== --- branches/asm/src/org/python/core/PyInstance.java 2008-08-02 08:49:57 UTC (rev 5052) +++ branches/asm/src/org/python/core/PyInstance.java 2008-08-02 19:51:15 UTC (rev 5053) @@ -264,7 +264,7 @@ } } if (f == null) f = ifindfunction(name); - if (f == null) throw Py.AttributeError(name); + if (f == null) noAttributeError(name); return f.__call__(); } @@ -281,7 +281,7 @@ } } if (f == null) f = ifindfunction(name); - if (f == null) throw Py.AttributeError(name); + if (f == null) noAttributeError(name); return f.__call__(arg1); } @@ -298,11 +298,16 @@ } } if (f == null) f = ifindfunction(name); - if (f == null) throw Py.AttributeError(name); + if (f == null) noAttributeError(name); return f.__call__(arg1, arg2); } + public void noAttributeError(String name) { + throw Py.AttributeError(String.format("%.50s instance has no attribute '%.400s'", + instclass.__name__, name)); + } + public void __setattr__(String name, PyObject value) { if (name == "__class__") { if (value instanceof PyClass) { Modified: branches/asm/src/org/python/core/PyObject.java =================================================================== --- branches/asm/src/org/python/core/PyObject.java 2008-08-02 08:49:57 UTC (rev 5052) +++ branches/asm/src/org/python/core/PyObject.java 2008-08-02 19:51:15 UTC (rev 5053) @@ -581,7 +581,8 @@ * @exception Py.KeyError if the key is not found in the container **/ public void __delitem__(PyObject key) { - throw Py.AttributeError("__delitem__"); + throw Py.TypeError(String.format("'%.200s' object doesn't support item deletion", + getType().fastGetName())); } /** @@ -1504,7 +1505,7 @@ * @return a string representing this object as a hexadecimal number. **/ public PyString __hex__() { - throw Py.AttributeError("__hex__"); + throw Py.TypeError("hex() argument can't be converted to hex"); } /** @@ -1515,7 +1516,7 @@ * @return a string representing this object as an octal number. **/ public PyString __oct__() { - throw Py.AttributeError("__oct__"); + throw Py.TypeError("oct() argument can't be converted to oct"); } /** @@ -1568,7 +1569,8 @@ * @return +this. **/ public PyObject __pos__() { - throw Py.AttributeError("__pos__"); + throw Py.TypeError(String.format("bad operand type for unary +: '%.200s'", + getType().fastGetName())); } /** @@ -1577,7 +1579,8 @@ * @return -this. **/ public PyObject __neg__() { - throw Py.AttributeError("__neg__"); + throw Py.TypeError(String.format("bad operand type for unary -: '%.200s'", + getType().fastGetName())); } /** @@ -1586,7 +1589,8 @@ * @return abs(this). **/ public PyObject __abs__() { - throw Py.AttributeError("__abs__"); + throw Py.TypeError(String.format("bad operand type for abs(): '%.200s'", + getType().fastGetName())); } /** @@ -1595,7 +1599,8 @@ * @return ~this. **/ public PyObject __invert__() { - throw Py.AttributeError("__invert__"); + throw Py.TypeError(String.format("bad operand type for unary ~: '%.200s'", + getType().fastGetName())); } /** Modified: branches/asm/src/org/python/core/__builtin__.java =================================================================== --- branches/asm/src/org/python/core/__builtin__.java 2008-08-02 08:49:57 UTC (rev 5052) +++ branches/asm/src/org/python/core/__builtin__.java 2008-08-02 19:51:15 UTC (rev 5053) @@ -387,10 +387,7 @@ } public static PyObject abs(PyObject o) { - if (o.isNumberType()) { - return o.__abs__(); - } - throw Py.TypeError("bad operand type for abs()"); + return o.__abs__(); } public static PyObject apply(PyObject o) { @@ -725,14 +722,7 @@ } public static PyString hex(PyObject o) { - try { - return o.__hex__(); - } catch (PyException e) { - if (Py.matchException(e, Py.AttributeError)) { - throw Py.TypeError("hex() argument can't be converted to hex"); - } - throw e; - } + return o.__hex__(); } public static long id(PyObject o) { @@ -856,14 +846,7 @@ } public static PyString oct(PyObject o) { - try { - return o.__oct__(); - } catch (PyException e) { - if (Py.matchException(e, Py.AttributeError)) { - throw Py.TypeError("oct() argument can't be converted to oct"); - } - throw e; - } + return o.__oct__(); } public static final int ord(PyObject c) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2008-08-02 08:50:00
|
Revision: 5052 http://jython.svn.sourceforge.net/jython/?rev=5052&view=rev Author: nriley Date: 2008-08-02 08:49:57 +0000 (Sat, 02 Aug 2008) Log Message: ----------- jna-posix from http://svn.codehaus.org/jruby-contrib/trunk/jna-posix r213 + patch in http://jira.codehaus.org/browse/JRUBY-2885 for isatty on Windows Modified Paths: -------------- branches/asm/extlibs/jna-posix.jar This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2008-08-02 08:48:14
|
Revision: 5051 http://jython.svn.sourceforge.net/jython/?rev=5051&view=rev Author: nriley Date: 2008-08-02 08:48:11 +0000 (Sat, 02 Aug 2008) Log Message: ----------- Handle scripts on stdin. Modified Paths: -------------- branches/asm/src/org/python/util/jython.java Modified: branches/asm/src/org/python/util/jython.java =================================================================== --- branches/asm/src/org/python/util/jython.java 2008-08-01 23:02:47 UTC (rev 5050) +++ branches/asm/src/org/python/util/jython.java 2008-08-02 08:48:11 UTC (rev 5051) @@ -144,6 +144,10 @@ // Decide if stdin is interactive if (!opts.fixInteractive && opts.interactive) { opts.interactive = ((PyFile)Py.defaultSystemState.stdin).isatty(); + if (!opts.interactive) { + PySystemState systemState = Py.getSystemState(); + systemState.ps1 = systemState.ps2 = new PyString(); + } } // Print banner and copyright information (or not) @@ -245,7 +249,7 @@ } } - if (opts.fixInteractive || opts.interactive) { + if (opts.fixInteractive || (opts.filename == null && opts.command == null)) { if (opts.encoding == null) { opts.encoding = PySystemState.registry.getProperty( "python.console.encoding", null); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2008-08-01 23:02:50
|
Revision: 5050 http://jython.svn.sourceforge.net/jython/?rev=5050&view=rev Author: nriley Date: 2008-08-01 23:02:47 +0000 (Fri, 01 Aug 2008) Log Message: ----------- JYTHONPATH support. Modified Paths: -------------- branches/asm/src/org/python/core/PySystemState.java branches/asm/src/org/python/util/jython.java Modified: branches/asm/src/org/python/core/PySystemState.java =================================================================== --- branches/asm/src/org/python/core/PySystemState.java 2008-08-01 22:38:32 UTC (rev 5049) +++ branches/asm/src/org/python/core/PySystemState.java 2008-08-01 23:02:47 UTC (rev 5050) @@ -440,13 +440,14 @@ } catch (Exception exc) { } } + try { + String jythonpath = System.getenv("JYTHONPATH"); + if (jythonpath != null) + registry.setProperty("python.path", jythonpath); + } catch (SecurityException e) { + } if (postProperties != null) { - for (Enumeration e=postProperties.keys(); e.hasMoreElements();) - { - String key = (String)e.nextElement(); - String value = (String)postProperties.get(key); - registry.put(key, value); - } + registry.putAll(postProperties); } if (standalone) { // set default standalone property (if not yet set) Modified: branches/asm/src/org/python/util/jython.java =================================================================== --- branches/asm/src/org/python/util/jython.java 2008-08-01 22:38:32 UTC (rev 5049) +++ branches/asm/src/org/python/util/jython.java 2008-08-01 23:02:47 UTC (rev 5050) @@ -54,7 +54,10 @@ //"-x : skip first line of source, allowing use of non-Unix forms of #!cmd\n" + "file : program read from script file\n" + "- : program read from stdin (default; interactive mode if a tty)\n" + - "arg ... : arguments passed to program in sys.argv[1:]"; + "arg ... : arguments passed to program in sys.argv[1:]\n" + + "Other environment variables:\n" + + "JYTHONPATH: '" + java.io.File.pathSeparator + "'-separated list of directories prefixed to the default module\n" + + " search path. The result is sys.path."; public static void runJar(String filename) { // TBD: this is kind of gross because a local called `zipfile' just This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-08-01 22:38:35
|
Revision: 5049 http://jython.svn.sourceforge.net/jython/?rev=5049&view=rev Author: pjenvey Date: 2008-08-01 22:38:32 +0000 (Fri, 01 Aug 2008) Log Message: ----------- list.__nonzero__ needn't be exposed, couple test_descrtut fixes (though it still fails due to parser problems) Modified Paths: -------------- branches/asm/Lib/test/test_descrtut.py branches/asm/src/org/python/core/PyList.java Modified: branches/asm/Lib/test/test_descrtut.py =================================================================== --- branches/asm/Lib/test/test_descrtut.py 2008-08-01 22:28:52 UTC (rev 5048) +++ branches/asm/Lib/test/test_descrtut.py 2008-08-01 22:38:32 UTC (rev 5049) @@ -73,7 +73,7 @@ >>> exec "x = 3; print x" in a 3 >>> print sorted(a.keys()) - [1, 2, '__builtins__', 'x'] + [1, 2, 'x'] >>> print a['x'] 3 >>> @@ -199,10 +199,10 @@ '__mul__', '__ne__', '__new__', + '__radd__', '__reduce__', '__reduce_ex__', '__repr__', - '__reversed__', '__rmul__', '__setattr__', '__setitem__', Modified: branches/asm/src/org/python/core/PyList.java =================================================================== --- branches/asm/src/org/python/core/PyList.java 2008-08-01 22:28:52 UTC (rev 5048) +++ branches/asm/src/org/python/core/PyList.java 2008-08-01 22:38:32 UTC (rev 5049) @@ -377,11 +377,6 @@ return ret; } - @ExposedMethod - final boolean list___nonzero__() { - return seq___nonzero__(); - } - public PyObject __iter__() { return list___iter__(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-08-01 22:28:55
|
Revision: 5048 http://jython.svn.sourceforge.net/jython/?rev=5048&view=rev Author: pjenvey Date: 2008-08-01 22:28:52 +0000 (Fri, 01 Aug 2008) Log Message: ----------- from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_descrtut.py@38295 Modified Paths: -------------- branches/asm/Lib/test/test_descrtut.py Modified: branches/asm/Lib/test/test_descrtut.py =================================================================== --- branches/asm/Lib/test/test_descrtut.py 2008-08-01 22:28:33 UTC (rev 5047) +++ branches/asm/Lib/test/test_descrtut.py 2008-08-01 22:28:52 UTC (rev 5048) @@ -8,7 +8,7 @@ # of much interest anymore), and a few were fiddled to make the output # deterministic. -from test_support import sortdict +from test.test_support import sortdict import pprint class defaultdict(dict): @@ -37,18 +37,18 @@ Here's the new type at work: >>> print defaultdict # show our type - <class 'test_descrtut.defaultdict'> + <class 'test.test_descrtut.defaultdict'> >>> print type(defaultdict) # its metatype <type 'type'> >>> a = defaultdict(default=0.0) # create an instance >>> print a # show the instance {} >>> print type(a) # show its type - <class 'test_descrtut.defaultdict'> + <class 'test.test_descrtut.defaultdict'> >>> print a.__class__ # show its class - <class 'test_descrtut.defaultdict'> + <class 'test.test_descrtut.defaultdict'> >>> print type(a) is a.__class__ # its type is its class - 1 + True >>> a[1] = 3.25 # modify the instance >>> print a # show the new value {1: 3.25} @@ -73,17 +73,11 @@ >>> exec "x = 3; print x" in a 3 >>> print sorted(a.keys()) - [1, 2, 'x'] + [1, 2, '__builtins__', 'x'] >>> print a['x'] 3 >>> -This work in Jython - - >>> exec "print foo" in a - 0.0 - >>> - Now I'll show that defaultdict instances have dynamic instance variables, just like classic classes: @@ -94,14 +88,14 @@ >>> print a["noway"] -1000 >>> 'default' in dir(a) - 1 + True >>> a.x1 = 100 >>> a.x2 = 200 >>> print a.x1 100 >>> d = dir(a) >>> 'default' in d and 'x1' in d and 'x2' in d - 1 + True >>> print sortdict(a.__dict__) {'default': -1000, 'x1': 100, 'x2': 200} >>> @@ -163,11 +157,11 @@ >>> list <type 'list'> >>> isinstance([], list) - 1 + True >>> isinstance([], dict) - 0 + False >>> isinstance([], object) - 1 + True >>> Under the new proposal, the __methods__ attribute no longer exists: @@ -198,22 +192,22 @@ '__iadd__', '__imul__', '__init__', + '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', - '__nonzero__', - '__radd__', '__reduce__', + '__reduce_ex__', '__repr__', + '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__str__', - '__unicode__', 'append', 'count', 'extend', @@ -224,7 +218,6 @@ 'reverse', 'sort'] - The new introspection API gives more information than the old one: in addition to the regular methods, it also shows the methods that are normally invoked through special notations, e.g. __iadd__ (+=), __len__ @@ -253,9 +246,9 @@ >>> class C: ... + ... @staticmethod ... def foo(x, y): ... print "staticmethod", x, y - ... foo = staticmethod(foo) >>> C.foo(1, 2) staticmethod 1 2 @@ -267,24 +260,24 @@ implicit first argument that is the *class* for which they are invoked. >>> class C: + ... @classmethod ... def foo(cls, y): ... print "classmethod", cls, y - ... foo = classmethod(foo) >>> C.foo(1) - classmethod test_descrtut.C 1 + classmethod test.test_descrtut.C 1 >>> c = C() >>> c.foo(1) - classmethod test_descrtut.C 1 + classmethod test.test_descrtut.C 1 >>> class D(C): ... pass >>> D.foo(1) - classmethod test_descrtut.D 1 + classmethod test.test_descrtut.D 1 >>> d = D() >>> d.foo(1) - classmethod test_descrtut.D 1 + classmethod test.test_descrtut.D 1 This prints "classmethod __main__.D 1" both times; in other words, the class passed as the first argument of foo() is the class involved in the @@ -293,18 +286,18 @@ But notice this: >>> class E(C): + ... @classmethod ... def foo(cls, y): # override C.foo ... print "E.foo() called" ... C.foo(y) - ... foo = classmethod(foo) >>> E.foo(1) E.foo() called - classmethod test_descrtut.C 1 + classmethod test.test_descrtut.C 1 >>> e = E() >>> e.foo(1) E.foo() called - classmethod test_descrtut.C 1 + classmethod test.test_descrtut.C 1 In this example, the call to C.foo() from E.foo() will see class C as its first argument, not class E. This is to be expected, since the call @@ -475,7 +468,7 @@ """ __test__ = {"tut1": test_1, - #"tut2": test_2, no slots right now + "tut2": test_2, "tut3": test_3, "tut4": test_4, "tut5": test_5, @@ -493,7 +486,7 @@ # into the doctest examples, and unless the full test.test_descrtut # business is used the name can change depending on how the test is # invoked. - import test_support, test_descrtut + from test import test_support, test_descrtut test_support.run_doctest(test_descrtut, verbose) # This part isn't needed for regrtest, but for running the test directly. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2008-08-01 22:28:37
|
Revision: 5047 http://jython.svn.sourceforge.net/jython/?rev=5047&view=rev Author: nriley Date: 2008-08-01 22:28:33 +0000 (Fri, 01 Aug 2008) Log Message: ----------- Read python.executable from whole registry, not just top level. Modified Paths: -------------- branches/asm/src/org/python/core/PySystemState.java Modified: branches/asm/src/org/python/core/PySystemState.java =================================================================== --- branches/asm/src/org/python/core/PySystemState.java 2008-08-01 21:49:29 UTC (rev 5046) +++ branches/asm/src/org/python/core/PySystemState.java 2008-08-01 22:28:33 UTC (rev 5047) @@ -636,7 +636,7 @@ * @return a PyObject path string or Py.None */ private static PyObject initExecutable(Properties props) { - String executable = (String)props.get("python.executable"); + String executable = props.getProperty("python.executable"); if (executable == null) { return Py.None; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |