From: <fwi...@us...> - 2008-05-24 14:56:36
|
Revision: 4442 http://jython.svn.sourceforge.net/jython/?rev=4442&view=rev Author: fwierzbicki Date: 2008-05-24 07:56:35 -0700 (Sat, 24 May 2008) Log Message: ----------- Broke out antlr parsing of Expressions (aka: evals). Start of a fix for evals with leading spaces. Extended PythonTreeWalker so eval and interactive parsing is supported. Modified Paths: -------------- trunk/jython/src/org/python/antlr/PythonGrammar.java trunk/jython/src/org/python/antlr/PythonTreeWalker.java trunk/jython/src/org/python/core/antlr.java Added Paths: ----------- trunk/jython/src/org/python/antlr/ExpressionParser.java trunk/jython/src/org/python/antlr/LeadingSpaceSkippingStream.java Added: trunk/jython/src/org/python/antlr/ExpressionParser.java =================================================================== --- trunk/jython/src/org/python/antlr/ExpressionParser.java (rev 0) +++ trunk/jython/src/org/python/antlr/ExpressionParser.java 2008-05-24 14:56:35 UTC (rev 4442) @@ -0,0 +1,73 @@ +package org.python.antlr; + +import org.antlr.runtime.CharStream; +import org.antlr.runtime.CommonToken; +import org.antlr.runtime.CommonTokenStream; +import org.antlr.runtime.RecognitionException; +import org.antlr.runtime.Token; +import org.antlr.runtime.tree.CommonTree; +import org.antlr.runtime.tree.CommonTreeAdaptor; +import org.antlr.runtime.tree.CommonTreeNodeStream; +import org.antlr.runtime.tree.Tree; +import org.antlr.runtime.tree.TreeAdaptor; +import org.python.antlr.ast.modType; +import org.python.antlr.ast.Module; +import org.python.antlr.ast.stmtType; + +public class ExpressionParser { + + private CharStream charStream; + + //Extract superclass from this and the other XParsers. + public static class PyLexer extends PythonLexer { + public PyLexer(CharStream lexer) { + super(lexer); + } + + public Token nextToken() { + startPos = getCharPositionInLine(); + return super.nextToken(); + } + } + + public static TreeAdaptor pyadaptor = new CommonTreeAdaptor() { + public Object create(Token token) { + return new PythonTree(token); + } + + public Object dupNode(Object t) { + if (t == null) { + return null; + } + return create(((PythonTree) t).token); + } + }; + + public ExpressionParser(CharStream cs) { + this.charStream = cs; + } + + public modType parse() { + modType tree = null; + PythonLexer lexer = new PyLexer(this.charStream); + CommonTokenStream tokens = new CommonTokenStream(lexer); + tokens.discardOffChannelTokens(true); + PythonTokenSource indentedSource = new PythonTokenSource(tokens); + tokens = new CommonTokenStream(indentedSource); + PythonParser parser = new PythonParser(tokens); + parser.setTreeAdaptor(pyadaptor); + + try { + Object rx = parser.eval_input(); + PythonParser.eval_input_return r = (PythonParser.eval_input_return)rx; + CommonTreeNodeStream nodes = new CommonTreeNodeStream((Tree)r.tree); + nodes.setTokenStream(tokens); + PythonWalker walker = new PythonWalker(nodes); + tree = walker.expression(); + } catch (RecognitionException e) { + // FIXME: + System.err.println("FIXME: don't eat exceptions:" + e); + } + return tree; + } +} Added: trunk/jython/src/org/python/antlr/LeadingSpaceSkippingStream.java =================================================================== --- trunk/jython/src/org/python/antlr/LeadingSpaceSkippingStream.java (rev 0) +++ trunk/jython/src/org/python/antlr/LeadingSpaceSkippingStream.java 2008-05-24 14:56:35 UTC (rev 4442) @@ -0,0 +1,26 @@ +package org.python.antlr; + +import java.io.InputStream; +import java.io.IOException; + +public class LeadingSpaceSkippingStream extends InputStream { + + private InputStream inputStream; + private boolean maybeLeadingSpaces = true; + + public LeadingSpaceSkippingStream(InputStream is) { + inputStream = is; + } + + public int read() throws IOException { + int i = inputStream.read(); + while (maybeLeadingSpaces) { + if (i != ' ') { + maybeLeadingSpaces = false; + } else { + i = inputStream.read(); + } + } + return i; + } +} Modified: trunk/jython/src/org/python/antlr/PythonGrammar.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonGrammar.java 2008-05-24 14:34:05 UTC (rev 4441) +++ trunk/jython/src/org/python/antlr/PythonGrammar.java 2008-05-24 14:56:35 UTC (rev 4442) @@ -86,7 +86,7 @@ tree = walker.module(); if (tree == null) { //XXX: seems like I should be able to get antlr to give me an empty Module instead - // of null so I wouldn't need to build an empty Moduel by hand here... + // of null so I wouldn't need to build an empty Module by hand here... return new Module(new PythonTree(new CommonToken(PyLexer.Module)), new stmtType[0]); } } catch (RecognitionException e) { @@ -97,31 +97,6 @@ } //XXX: factor out common code. - public modType eval_input() { - modType tree = null; - PythonLexer lexer = new PyLexer(this.charStream); - CommonTokenStream tokens = new CommonTokenStream(lexer); - tokens.discardOffChannelTokens(true); - PythonTokenSource indentedSource = new PythonTokenSource(tokens); - tokens = new CommonTokenStream(indentedSource); - PythonParser parser = new PythonParser(tokens); - parser.setTreeAdaptor(pyadaptor); - - try { - Object rx = parser.eval_input(); - PythonParser.eval_input_return r = (PythonParser.eval_input_return)rx; - CommonTreeNodeStream nodes = new CommonTreeNodeStream((Tree)r.tree); - nodes.setTokenStream(tokens); - PythonWalker walker = new PythonWalker(nodes); - tree = walker.expression(); - } catch (RecognitionException e) { - // FIXME: - System.err.println("FIXME: don't eat exceptions:" + e); - } - return tree; - } - - //XXX: factor out common code. public modType single_input() { modType tree = null; PythonLexer lexer = new PyLexer(this.charStream); Modified: trunk/jython/src/org/python/antlr/PythonTreeWalker.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTreeWalker.java 2008-05-24 14:34:05 UTC (rev 4441) +++ trunk/jython/src/org/python/antlr/PythonTreeWalker.java 2008-05-24 14:56:35 UTC (rev 4442) @@ -15,12 +15,16 @@ */ public class PythonTreeWalker { + public enum Block { MODULE, INTERACTIVE, EXPRESSION }; + private boolean _parseOnly; private boolean _tolerant; + private Block _block; public PythonTreeWalker() { setParseOnly(false); setTolerant(true); + setBlock(Block.MODULE); } public PythonTree parse(String[] args) throws Exception { @@ -31,11 +35,22 @@ tokens.discardOffChannelTokens(true); PythonTokenSource indentedSource = new PythonTokenSource(tokens); tokens = new CommonTokenStream(indentedSource); - // System.out.println("tokens="+tokens.getTokens()); PythonParser parser = new PythonParser(tokens); parser.setTreeAdaptor(PythonGrammar.pyadaptor); try { - PythonParser.file_input_return r = parser.file_input(); + Tree r = null; + switch (_block) { + case MODULE : + r = (Tree)parser.file_input().tree; + break; + case INTERACTIVE : + r = (Tree)parser.single_input().tree; + break; + case EXPRESSION : + r = (Tree)parser.eval_input().tree; + break; + } + //Tree r = (Tree)parser.file_input().tree; if (parser.hasErrors()) { // handle errors swallowed by antlr recovery String errors = parser.getErrors().toString(); @@ -46,13 +61,24 @@ } } if (args.length > 1) { - System.out.println(((Tree) r.tree).toStringTree()); + System.out.println((r).toStringTree()); } if (!isParseOnly()) { - CommonTreeNodeStream nodes = new CommonTreeNodeStream((Tree) r.tree); + CommonTreeNodeStream nodes = new CommonTreeNodeStream(r); nodes.setTokenStream(tokens); PythonWalker walker = new PythonWalker(nodes); - result = walker.module(); + switch (_block) { + case MODULE : + result = walker.module(); + break; + case INTERACTIVE : + result = walker.interactive(); + break; + case EXPRESSION : + result = walker.expression(); + break; + } + if (args.length > 1) { System.out.println(result.toStringTree()); } @@ -95,4 +121,12 @@ return _tolerant; } + public void setBlock(Block block) { + _block = block; + } + + public Block getBlock() { + return _block; + } + } Modified: trunk/jython/src/org/python/core/antlr.java =================================================================== --- trunk/jython/src/org/python/core/antlr.java 2008-05-24 14:34:05 UTC (rev 4441) +++ trunk/jython/src/org/python/core/antlr.java 2008-05-24 14:56:35 UTC (rev 4442) @@ -12,6 +12,8 @@ import org.antlr.runtime.ANTLRReaderStream; import org.antlr.runtime.CharStream; import org.antlr.runtime.RecognitionException; +import org.python.antlr.ExpressionParser; +import org.python.antlr.LeadingSpaceSkippingStream; import org.python.antlr.PythonGrammar; import org.python.core.util.StringUtil; import org.python.antlr.IParserHost; @@ -92,22 +94,23 @@ public static modType parse(InputStream istream, String kind, String filename, CompilerFlags cflags) { - BufferedReader bufreader = prepBufreader(istream, cflags); - /* FJW FJW - PythonGrammar g = new PythonGrammar(new ReaderCharStream(bufreader), - literalMkrForParser); - */ CharStream cs = null; - try { - cs = new ANTLRReaderStream(bufreader); - } catch (IOException io){ - //FIXME: - System.err.println("FIXME: Don't eat exceptions."); - } - PythonGrammar g = new PythonGrammar(cs);//FJW, literalMkrForParser); + //FIXME: definite NPE potential here -- do we even need prepBufreader + // now? + BufferedReader bufreader = null; modType node = null; try { - node = doparse(kind, cflags, g); + if (kind.equals("eval")) { + bufreader = prepBufreader(new LeadingSpaceSkippingStream(istream), cflags); + cs = new ANTLRReaderStream(bufreader); + ExpressionParser e = new ExpressionParser(cs); + node = e.parse(); + } else { + bufreader = prepBufreader(istream, cflags); + cs = new ANTLRReaderStream(bufreader); + PythonGrammar g = new PythonGrammar(cs);//FJW, literalMkrForParser); + node = doparse(kind, cflags, g); + } } catch (Throwable t) { throw fixParseError(bufreader, t, filename); @@ -162,10 +165,7 @@ //FJW if (cflags != null) //FJW g.token_source.generator_allowed = cflags.generator_allowed; - if (kind.equals("eval")) { - node = g.eval_input(); - } - else if (kind.equals("exec")) { + if (kind.equals("exec")) { node = g.file_input(); } else if (kind.equals("single")) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-05-27 18:48:25
|
Revision: 4462 http://jython.svn.sourceforge.net/jython/?rev=4462&view=rev Author: fwierzbicki Date: 2008-05-27 11:48:24 -0700 (Tue, 27 May 2008) Log Message: ----------- Some cleanup of the parser driving classes. Modified Paths: -------------- trunk/jython/src/org/python/antlr/ExpressionParser.java trunk/jython/src/org/python/antlr/PythonGrammar.java trunk/jython/src/org/python/core/antlr.java Added Paths: ----------- trunk/jython/src/org/python/antlr/InteractiveParser.java Modified: trunk/jython/src/org/python/antlr/ExpressionParser.java =================================================================== --- trunk/jython/src/org/python/antlr/ExpressionParser.java 2008-05-27 17:05:17 UTC (rev 4461) +++ trunk/jython/src/org/python/antlr/ExpressionParser.java 2008-05-27 18:48:24 UTC (rev 4462) @@ -47,7 +47,7 @@ this.charStream = cs; } - public modType parse() { + public modType parse() throws RecognitionException { modType tree = null; PythonLexer lexer = new PyLexer(this.charStream); CommonTokenStream tokens = new CommonTokenStream(lexer); @@ -57,17 +57,12 @@ PythonParser parser = new PythonParser(tokens); parser.setTreeAdaptor(pyadaptor); - try { - Object rx = parser.eval_input(); - PythonParser.eval_input_return r = (PythonParser.eval_input_return)rx; - CommonTreeNodeStream nodes = new CommonTreeNodeStream((Tree)r.tree); - nodes.setTokenStream(tokens); - PythonWalker walker = new PythonWalker(nodes); - tree = walker.expression(); - } catch (RecognitionException e) { - // FIXME: - System.err.println("FIXME: don't eat exceptions:" + e); - } + Object rx = parser.eval_input(); + PythonParser.eval_input_return r = (PythonParser.eval_input_return)rx; + CommonTreeNodeStream nodes = new CommonTreeNodeStream((Tree)r.tree); + nodes.setTokenStream(tokens); + PythonWalker walker = new PythonWalker(nodes); + tree = walker.expression(); return tree; - } + } } Added: trunk/jython/src/org/python/antlr/InteractiveParser.java =================================================================== --- trunk/jython/src/org/python/antlr/InteractiveParser.java (rev 0) +++ trunk/jython/src/org/python/antlr/InteractiveParser.java 2008-05-27 18:48:24 UTC (rev 4462) @@ -0,0 +1,68 @@ +package org.python.antlr; + +import org.antlr.runtime.CharStream; +import org.antlr.runtime.CommonToken; +import org.antlr.runtime.CommonTokenStream; +import org.antlr.runtime.RecognitionException; +import org.antlr.runtime.Token; +import org.antlr.runtime.tree.CommonTree; +import org.antlr.runtime.tree.CommonTreeAdaptor; +import org.antlr.runtime.tree.CommonTreeNodeStream; +import org.antlr.runtime.tree.Tree; +import org.antlr.runtime.tree.TreeAdaptor; +import org.python.antlr.ast.modType; +import org.python.antlr.ast.Module; +import org.python.antlr.ast.stmtType; + +public class InteractiveParser { + + private CharStream charStream; + + //Extract superclass from this and the other XParsers. + public static class PyLexer extends PythonLexer { + public PyLexer(CharStream lexer) { + super(lexer); + } + + public Token nextToken() { + startPos = getCharPositionInLine(); + return super.nextToken(); + } + } + + public static TreeAdaptor pyadaptor = new CommonTreeAdaptor() { + public Object create(Token token) { + return new PythonTree(token); + } + + public Object dupNode(Object t) { + if (t == null) { + return null; + } + return create(((PythonTree) t).token); + } + }; + + public InteractiveParser(CharStream cs) { + this.charStream = cs; + } + + public modType parse() throws RecognitionException { + modType tree = null; + PythonLexer lexer = new PyLexer(this.charStream); + CommonTokenStream tokens = new CommonTokenStream(lexer); + tokens.discardOffChannelTokens(true); + PythonTokenSource indentedSource = new PythonTokenSource(tokens); + tokens = new CommonTokenStream(indentedSource); + PythonParser parser = new PythonParser(tokens); + parser.setTreeAdaptor(pyadaptor); + + Object rx = parser.single_input(); + PythonParser.single_input_return r = (PythonParser.single_input_return)rx; + CommonTreeNodeStream nodes = new CommonTreeNodeStream((Tree)r.tree); + nodes.setTokenStream(tokens); + PythonWalker walker = new PythonWalker(nodes); + tree = walker.interactive(); + return tree; + } +} Modified: trunk/jython/src/org/python/antlr/PythonGrammar.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonGrammar.java 2008-05-27 17:05:17 UTC (rev 4461) +++ trunk/jython/src/org/python/antlr/PythonGrammar.java 2008-05-27 18:48:24 UTC (rev 4462) @@ -52,21 +52,6 @@ this.charStream = cs; } - public void printTree(CommonTree t, int indent) { - if (t != null) { - System.out.println("XXX: " + t.toString() + t.getType()); - StringBuffer sb = new StringBuffer(indent); - for (int i = 0; i < indent; i++) { - sb = sb.append(" "); - } - for (int i = 0; i < t.getChildCount(); i++) { - System.out.println(sb.toString() + t.getChild(i).toString() + ":" + t.getChild(i).getType()); - printTree((CommonTree) t.getChild(i), indent + 1); - } - } - } - - //XXX: factor out common code. public modType file_input() throws RecognitionException { modType tree = null; PythonLexer lexer = new PyLexer(this.charStream); @@ -90,23 +75,4 @@ } return tree; } - - //XXX: factor out common code. - public modType single_input() throws RecognitionException { - modType tree = null; - PythonLexer lexer = new PyLexer(this.charStream); - CommonTokenStream tokens = new CommonTokenStream(lexer); - tokens.discardOffChannelTokens(true); - PythonTokenSource indentedSource = new PythonTokenSource(tokens); - tokens = new CommonTokenStream(indentedSource); - PythonParser parser = new PythonParser(tokens); - parser.setTreeAdaptor(pyadaptor); - Object rx = parser.single_input(); - PythonParser.single_input_return r = (PythonParser.single_input_return)rx; - CommonTreeNodeStream nodes = new CommonTreeNodeStream((Tree)r.tree); - nodes.setTokenStream(tokens); - PythonWalker walker = new PythonWalker(nodes); - tree = walker.interactive(); - return tree; - } } Modified: trunk/jython/src/org/python/core/antlr.java =================================================================== --- trunk/jython/src/org/python/core/antlr.java 2008-05-27 17:05:17 UTC (rev 4461) +++ trunk/jython/src/org/python/core/antlr.java 2008-05-27 18:48:24 UTC (rev 4462) @@ -14,6 +14,7 @@ import org.antlr.runtime.RecognitionException; import org.antlr.runtime.*; import org.python.antlr.ExpressionParser; +import org.python.antlr.InteractiveParser; import org.python.antlr.LeadingSpaceSkippingStream; import org.python.antlr.ParseException; import org.python.antlr.PythonGrammar; @@ -184,10 +185,15 @@ cs = new ANTLRReaderStream(bufreader); ExpressionParser e = new ExpressionParser(cs); node = e.parse(); + } else if (kind.equals("single")) { + bufreader = prepBufreader(istream, cflags); + cs = new ANTLRReaderStream(bufreader); + InteractiveParser i = new InteractiveParser(cs); + node = i.parse(); } else { bufreader = prepBufreader(istream, cflags); cs = new ANTLRReaderStream(bufreader); - PythonGrammar g = new PythonGrammar(cs);//FJW, literalMkrForParser); + PythonGrammar g = new PythonGrammar(cs); node = doparse(kind, cflags, g); } } @@ -200,40 +206,44 @@ public static modType partialParse(String string, String kind, String filename, CompilerFlags cflags,boolean stdprompt) { - modType node = null; - BufferedReader bufreader = prepBufreader(new ByteArrayInputStream(StringUtil.toBytes(string)), - cflags); - - CharStream cs = null; - try { - cs = new ANTLRReaderStream(bufreader); - } catch (IOException io){ - //FIXME: - System.err.println("FIXME: Don't eat exceptions."); - } - PythonGrammar g = new PythonGrammar(cs, true); - //FJW g.token_source.partial = true; - //FJW g.token_source.stdprompt = stdprompt; - - try { - node = doparse(kind, cflags, g); - } - catch (Throwable t) { - /* - CPython codeop exploits that with CPython parser adding newlines - to a partial valid sentence move the reported error position, - this is not true for our parser, so we need a different approach: - we check whether all sentence tokens have been consumed or - the remaining ones fullfill lookahead expectations. See: - PythonGrammar.partial_valid_sentence (def in python.jjt) - */ - - //FJW if (g.partial_valid_sentence(t)) { - //FJW return null; - //FJW } - throw fixParseError(bufreader, t, filename); - } - return node; +//FIXME: FJW -- just doing "parse" for now until I come up with a partial parse +// strategy for antlr. 3.1 is supposed to have some kind of direct +// support for incremental parsing -- hopefully that can be used. + return parse(new ByteArrayInputStream(StringUtil.toBytes(string)), kind, filename, cflags); +// modType node = null; +// BufferedReader bufreader = prepBufreader(new ByteArrayInputStream(StringUtil.toBytes(string)), +// cflags); +// +// CharStream cs = null; +// try { +// cs = new ANTLRReaderStream(bufreader); +// } catch (IOException io){ +// //FIXME: +// System.err.println("FIXME: Don't eat exceptions."); +// } +// PythonGrammar g = new PythonGrammar(cs, true); +// //FJW g.token_source.partial = true; +// //FJW g.token_source.stdprompt = stdprompt; +// +// try { +// node = doparse(kind, cflags, g); +// } +// catch (Throwable t) { +// /* +// CPython codeop exploits that with CPython parser adding newlines +// to a partial valid sentence move the reported error position, +// this is not true for our parser, so we need a different approach: +// we check whether all sentence tokens have been consumed or +// the remaining ones fullfill lookahead expectations. See: +// PythonGrammar.partial_valid_sentence (def in python.jjt) +// */ +// +// //FJW if (g.partial_valid_sentence(t)) { +// //FJW return null; +// //FJW } +// throw fixParseError(bufreader, t, filename); +// } +// return node; } private static modType doparse(String kind, CompilerFlags cflags, @@ -247,9 +257,6 @@ if (kind.equals("exec")) { node = g.file_input(); } - else if (kind.equals("single")) { - node = g.single_input(); - } else { throw Py.ValueError("parse kind must be eval, exec, " + "or single"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-06-08 20:50:32
|
Revision: 4568 http://jython.svn.sourceforge.net/jython/?rev=4568&view=rev Author: pjenvey Date: 2008-06-08 13:50:30 -0700 (Sun, 08 Jun 2008) Log Message: ----------- o more resilient parsing of headURL o fix sys.version to not be preceeded with 'Jython' Modified Paths: -------------- trunk/jython/src/org/python/Version.java trunk/jython/src/org/python/util/InteractiveConsole.java Modified: trunk/jython/src/org/python/Version.java =================================================================== --- trunk/jython/src/org/python/Version.java 2008-06-08 04:36:23 UTC (rev 4567) +++ trunk/jython/src/org/python/Version.java 2008-06-08 20:50:30 UTC (rev 4568) @@ -51,25 +51,25 @@ loadProperties(); int jython = headURL.indexOf("/jython/"); - if (jython == -1) { - BRANCH = ""; - SHORT_BRANCH = "unknown"; - return; - } + if (jython > -1) { + int brStart = jython + 8; + String end = headURL.substring(brStart, headURL.length()); - int brStart = jython + 8; - int brEnd = headURL.indexOf('/', brStart); - int brEnd2 = headURL.indexOf('/', brEnd + 1); - - boolean isTag = "tags".equals(headURL.substring(brStart, brStart + 4)); - if ("trunk".equals(headURL.substring(brStart, brStart + 5))) { - BRANCH = SHORT_BRANCH = "trunk"; - } else if (isTag || "branches".equals(headURL.substring(brStart, brStart + 8))) { - int len = brEnd2 - brStart; - BRANCH = headURL.substring(brStart, brStart + len); - len = brEnd2 - (brEnd + 1); - SHORT_BRANCH = headURL.substring(brEnd + 1, brEnd + 1 + len); + if (end.startsWith("trunk/")) { + BRANCH = SHORT_BRANCH = "trunk"; + return; + } else if (end.startsWith("tags/") || end.startsWith("branches/")) { + int brEnd = end.indexOf('/'); + int brEnd2 = end.indexOf('/', brEnd + 1); + if (brEnd2 > -1) { + BRANCH = end.substring(0, brEnd2); + SHORT_BRANCH = end.substring(brEnd + 1, brEnd2); + return; + } + } } + BRANCH = ""; + SHORT_BRANCH = "unknown"; } /** @@ -142,6 +142,6 @@ * the Java VM). */ public static String getVersion() { - return String.format("Jython %.73s (%.80s) %.80s", PY_VERSION, getBuildInfo(), getVM()); + return String.format("%.80s (%.80s) %.80s", PY_VERSION, getBuildInfo(), getVM()); } } Modified: trunk/jython/src/org/python/util/InteractiveConsole.java =================================================================== --- trunk/jython/src/org/python/util/InteractiveConsole.java 2008-06-08 04:36:23 UTC (rev 4567) +++ trunk/jython/src/org/python/util/InteractiveConsole.java 2008-06-08 20:50:30 UTC (rev 4568) @@ -61,7 +61,7 @@ } public static String getDefaultBanner() { - return String.format("%s on %s", PySystemState.version, PySystemState.platform); + return String.format("Jython %s on %s", PySystemState.version, PySystemState.platform); } public void interact(String banner) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-06-09 06:49:37
|
Revision: 4583 http://jython.svn.sourceforge.net/jython/?rev=4583&view=rev Author: pjenvey Date: 2008-06-08 23:49:36 -0700 (Sun, 08 Jun 2008) Log Message: ----------- o add support for utf8 and utf16 decoders decoding incomplete input. from CPython r37292 (the rest being in the 2.4 stdlib) o fix _codecs.utf_16_decode supporting an optional byteorder arg when only utf_16_ex_decode should Modified Paths: -------------- trunk/jython/src/org/python/core/codecs.java trunk/jython/src/org/python/modules/_codecs.java Modified: trunk/jython/src/org/python/core/codecs.java =================================================================== --- trunk/jython/src/org/python/core/codecs.java 2008-06-09 03:09:46 UTC (rev 4582) +++ trunk/jython/src/org/python/core/codecs.java 2008-06-09 06:49:36 UTC (rev 4583) @@ -703,11 +703,16 @@ public static String PyUnicode_DecodeUTF8(String str, String errors) { + return PyUnicode_DecodeUTF8Stateful(str, errors, null); + } + + public static String PyUnicode_DecodeUTF8Stateful(String str, String errors, int[] consumed) { int size = str.length(); StringBuffer unicode = new StringBuffer(size); /* Unpack UTF-8 encoded data */ - for (int i = 0; i < size; ) { + int i; + for (i = 0; i < size; ) { int ch = str.charAt(i); if (ch < 0x80) { @@ -723,6 +728,9 @@ int n = utf8_code_length[ch]; if (i + n > size) { + if (consumed != null) { + break; + } i = insertReplacementAndGetResume(unicode, errors, "utf-8", str, i, i + 1, "unexpected end of data"); continue; } @@ -804,6 +812,10 @@ i += n; } + if (consumed != null) { + consumed[0] = i; + } + return unicode.toString(); } Modified: trunk/jython/src/org/python/modules/_codecs.java =================================================================== --- trunk/jython/src/org/python/modules/_codecs.java 2008-06-09 03:09:46 UTC (rev 4582) +++ trunk/jython/src/org/python/modules/_codecs.java 2008-06-09 06:49:36 UTC (rev 4583) @@ -57,10 +57,14 @@ } public static PyTuple utf_8_decode(String str, String errors) { - int size = str.length(); - return decode_tuple(codecs.PyUnicode_DecodeUTF8(str, errors), size); + return utf_8_decode(str, errors, false); } + public static PyTuple utf_8_decode(String str, String errors, boolean final_) { + int[] consumed = final_ ? new int[1] : null; + return decode_tuple(codecs.PyUnicode_DecodeUTF8Stateful(str, errors, consumed), + final_ ? consumed[0] : str.length()); + } public static PyTuple utf_8_encode(String str) { return utf_8_encode(str, null); @@ -380,13 +384,14 @@ } public static PyTuple utf_16_decode(String str, String errors) { - return utf_16_decode(str, errors, 0); + return utf_16_decode(str, errors, false); } - public static PyTuple utf_16_decode(String str, String errors, - int byteorder) { - int[] bo = new int[] { byteorder }; - return decode_tuple(decode_UTF16(str, errors, bo), str.length()); + public static PyTuple utf_16_decode(String str, String errors, boolean final_) { + int[] bo = new int[] { 0 }; + int[] consumed = final_ ? new int[1] : null; + return decode_tuple(decode_UTF16(str, errors, bo, consumed), + final_ ? consumed[0] : str.length()); } public static PyTuple utf_16_le_decode(String str) { @@ -394,8 +399,14 @@ } public static PyTuple utf_16_le_decode(String str, String errors) { + return utf_16_le_decode(str, errors, false); + } + + public static PyTuple utf_16_le_decode(String str, String errors, boolean final_) { int[] bo = new int[] { -1 }; - return decode_tuple(decode_UTF16(str, errors, bo), str.length()); + int[] consumed = final_ ? new int[1] : null; + return decode_tuple(decode_UTF16(str, errors, bo, consumed), + final_ ? consumed[0] : str.length()); } public static PyTuple utf_16_be_decode(String str) { @@ -403,8 +414,14 @@ } public static PyTuple utf_16_be_decode(String str, String errors) { + return utf_16_be_decode(str, errors, false); + } + + public static PyTuple utf_16_be_decode(String str, String errors, boolean final_) { int[] bo = new int[] { 1 }; - return decode_tuple(decode_UTF16(str, errors, bo), str.length()); + int[] consumed = final_ ? new int[1] : null; + return decode_tuple(decode_UTF16(str, errors, bo, consumed), + final_ ? consumed[0] : str.length()); } public static PyTuple utf_16_ex_decode(String str) { @@ -415,24 +432,41 @@ return utf_16_ex_decode(str, errors, 0); } - public static PyTuple utf_16_ex_decode(String str, String errors, - int byteorder) { + public static PyTuple utf_16_ex_decode(String str, String errors, int byteorder) { + return utf_16_ex_decode(str, errors, byteorder, false); + } + + public static PyTuple utf_16_ex_decode(String str, String errors, int byteorder, + boolean final_) { int[] bo = new int[] { 0 }; - String s = decode_UTF16(str, errors, bo); - return new PyTuple(Py.newString(s), Py.newInteger(str.length()), Py.newInteger(bo[0])); + int[] consumed = final_ ? new int[1] : null; + String decoded = decode_UTF16(str, errors, bo, consumed); + return new PyTuple(Py.newString(decoded), + Py.newInteger(final_ ? consumed[0] : str.length()), + Py.newInteger(bo[0])); } private static String decode_UTF16(String str, String errors, int[] byteorder) { + return decode_UTF16(str, errors, byteorder, null); + } + + private static String decode_UTF16(String str, String errors, int[] byteorder, + int[] consumed) { int bo = 0; if(byteorder != null) bo = byteorder[0]; + // XXX: check for BOM marks int size = str.length(); StringBuffer v = new StringBuffer(size / 2); - for(int i = 0; i < size; i += 2) { + int i; + for(i = 0; i < size; i += 2) { char ch1 = str.charAt(i); if(i + 1 == size) { + if (consumed != null) { + break; + } i = codecs.insertReplacementAndGetResume(v, errors, "utf-16", @@ -484,8 +518,13 @@ i + 1, "illegal encoding"); } + if(byteorder != null) byteorder[0] = bo; + if (consumed != null) { + consumed[0] = i; + } + return v.toString(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-06-13 01:34:19
|
Revision: 4609 http://jython.svn.sourceforge.net/jython/?rev=4609&view=rev Author: pjenvey Date: 2008-06-12 18:34:13 -0700 (Thu, 12 Jun 2008) Log Message: ----------- the compiler shouldn't inherit the compiler flags from the current frame on import as this causes futures to leak into different modules. this was done for #1691096 which is actaully an invalid bug fixes #1886758 Modified Paths: -------------- trunk/jython/src/org/python/compiler/Module.java trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/src/org/python/compiler/Module.java =================================================================== --- trunk/jython/src/org/python/compiler/Module.java 2008-06-12 21:08:38 UTC (rev 4608) +++ trunk/jython/src/org/python/compiler/Module.java 2008-06-13 01:34:13 UTC (rev 4609) @@ -6,6 +6,7 @@ import java.util.*; import org.python.parser.*; import org.python.parser.ast.*; +import org.python.core.CompilerFlags; import org.python.core.Py; import org.python.core.PyException; @@ -666,6 +667,9 @@ { Module module = new Module(name, filename, linenumbers); module.setFile = setFile; + if (cflags == null) { + cflags = new CompilerFlags(); + } module.futures.preprocessFutures(node, cflags); new ScopesCompiler(module, module.scopes).parse(node); Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2008-06-12 21:08:38 UTC (rev 4608) +++ trunk/jython/src/org/python/core/imp.java 2008-06-13 01:34:13 UTC (rev 4609) @@ -194,7 +194,7 @@ } org.python.parser.ast.modType node; try { - node = parser.parse(fp, "exec", filename, Py.getCompilerFlags()); + node = parser.parse(fp, "exec", filename, new CompilerFlags()); } finally { fp.close(); } @@ -205,7 +205,7 @@ true, false, true, - Py.getCompilerFlags()); + null); 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: <pj...@us...> - 2008-06-14 19:59:47
|
Revision: 4623 http://jython.svn.sourceforge.net/jython/?rev=4623&view=rev Author: pjenvey Date: 2008-06-14 12:59:37 -0700 (Sat, 14 Jun 2008) Log Message: ----------- o __delslice__ step is optional o fix ProxyType to use the canonical version of __setslice__ Modified Paths: -------------- trunk/jython/src/org/python/core/PyArray.java trunk/jython/src/org/python/core/PyList.java trunk/jython/src/org/python/modules/_weakref/ProxyType.java Modified: trunk/jython/src/org/python/core/PyArray.java =================================================================== --- trunk/jython/src/org/python/core/PyArray.java 2008-06-14 19:48:57 UTC (rev 4622) +++ trunk/jython/src/org/python/core/PyArray.java 2008-06-14 19:59:37 UTC (rev 4623) @@ -222,7 +222,7 @@ seq___setslice__(start, stop, step, value); } - @ExposedMethod + @ExposedMethod(defaults = "null") final void array___delslice__(PyObject start, PyObject stop, PyObject step) { seq___delslice__(start, stop, step); } Modified: trunk/jython/src/org/python/core/PyList.java =================================================================== --- trunk/jython/src/org/python/core/PyList.java 2008-06-14 19:48:57 UTC (rev 4622) +++ trunk/jython/src/org/python/core/PyList.java 2008-06-14 19:59:37 UTC (rev 4623) @@ -398,7 +398,7 @@ seq___setslice__(start, stop, step, value); } - @ExposedMethod + @ExposedMethod(defaults = "null") final void list___delslice__(PyObject start, PyObject stop, PyObject step) { seq___delslice__(start, stop, step); } Modified: trunk/jython/src/org/python/modules/_weakref/ProxyType.java =================================================================== --- trunk/jython/src/org/python/modules/_weakref/ProxyType.java 2008-06-14 19:48:57 UTC (rev 4622) +++ trunk/jython/src/org/python/modules/_weakref/ProxyType.java 2008-06-14 19:59:37 UTC (rev 4623) @@ -37,8 +37,8 @@ public PyObject __getslice__(PyObject start, PyObject stop, PyObject step) { return py().__getslice__(start, stop, step); } - public void __setslice__(PyObject start, PyObject stop, PyObject step) { - py().__setslice__(start, stop, step); + public void __setslice__(PyObject start, PyObject stop, PyObject step, PyObject value) { + py().__setslice__(start, stop, step, value); } public void __delslice__(PyObject start, PyObject stop, PyObject step) { py().__delslice__(start, stop, step); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-06-16 13:17:04
|
Revision: 4649 http://jython.svn.sourceforge.net/jython/?rev=4649&view=rev Author: fwierzbicki Date: 2008-06-16 06:17:01 -0700 (Mon, 16 Jun 2008) Log Message: ----------- Renamed test classes to clearly label them as testers. Eventually these should be moved out of the core src. Modified Paths: -------------- trunk/jython/src/org/python/core/PyString.java Added Paths: ----------- trunk/jython/src/org/python/antlr/GrammarTester.java trunk/jython/src/org/python/antlr/PythonTreeTester.java trunk/jython/src/org/python/antlr/WalkerTester.java Removed Paths: ------------- trunk/jython/src/org/python/antlr/GrammarOnly.java trunk/jython/src/org/python/antlr/Main.java trunk/jython/src/org/python/antlr/PythonTreeWalker.java Deleted: trunk/jython/src/org/python/antlr/GrammarOnly.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarOnly.java 2008-06-16 05:23:39 UTC (rev 4648) +++ trunk/jython/src/org/python/antlr/GrammarOnly.java 2008-06-16 13:17:01 UTC (rev 4649) @@ -1,12 +0,0 @@ -package org.python.antlr; - -public class GrammarOnly { - - public static void main(String[] args) throws Exception { - PythonTreeWalker walker = new PythonTreeWalker(); - walker.setTolerant(true); - walker.setParseOnly(true); - walker.parse(args); - } - -} Copied: trunk/jython/src/org/python/antlr/GrammarTester.java (from rev 4648, trunk/jython/src/org/python/antlr/GrammarOnly.java) =================================================================== --- trunk/jython/src/org/python/antlr/GrammarTester.java (rev 0) +++ trunk/jython/src/org/python/antlr/GrammarTester.java 2008-06-16 13:17:01 UTC (rev 4649) @@ -0,0 +1,12 @@ +package org.python.antlr; + +public class GrammarTester { + + public static void main(String[] args) throws Exception { + PythonTreeTester walker = new PythonTreeTester(); + walker.setTolerant(true); + walker.setParseOnly(true); + walker.parse(args); + } + +} Deleted: trunk/jython/src/org/python/antlr/Main.java =================================================================== --- trunk/jython/src/org/python/antlr/Main.java 2008-06-16 05:23:39 UTC (rev 4648) +++ trunk/jython/src/org/python/antlr/Main.java 2008-06-16 13:17:01 UTC (rev 4649) @@ -1,12 +0,0 @@ -package org.python.antlr; - -public class Main extends PythonTreeWalker { - - public static void main(String[] args) throws Exception { - PythonTreeWalker walker = new PythonTreeWalker(); - walker.setTolerant(true); - walker.setParseOnly(false); - walker.parse(args); - } - -} Copied: trunk/jython/src/org/python/antlr/PythonTreeTester.java (from rev 4648, trunk/jython/src/org/python/antlr/PythonTreeWalker.java) =================================================================== --- trunk/jython/src/org/python/antlr/PythonTreeTester.java (rev 0) +++ trunk/jython/src/org/python/antlr/PythonTreeTester.java 2008-06-16 13:17:01 UTC (rev 4649) @@ -0,0 +1,132 @@ +package org.python.antlr; + +import org.antlr.runtime.ANTLRFileStream; +import org.antlr.runtime.CharStream; +import org.antlr.runtime.CommonTokenStream; +import org.antlr.runtime.RecognitionException; +import org.antlr.runtime.Token; +import org.antlr.runtime.tree.CommonTreeAdaptor; +import org.antlr.runtime.tree.CommonTreeNodeStream; +import org.antlr.runtime.tree.Tree; +import org.antlr.runtime.tree.TreeAdaptor; + +/** + * A walker producing a <code>PythonTree</code> AST. + */ +public class PythonTreeTester { + + public enum Block { MODULE, INTERACTIVE, EXPRESSION }; + + private boolean _parseOnly; + private boolean _tolerant; + private Block _block; + + public PythonTreeTester() { + setParseOnly(false); + setTolerant(true); + setBlock(Block.MODULE); + } + + public PythonTree parse(String[] args) throws Exception { + PythonTree result = null; + CharStream input = new ANTLRFileStream(args[0]); + PythonLexer lexer = new PythonGrammar.PyLexer(input); + CommonTokenStream tokens = new CommonTokenStream(lexer); + tokens.discardOffChannelTokens(true); + PythonTokenSource indentedSource = new PythonTokenSource(tokens); + tokens = new CommonTokenStream(indentedSource); + PythonParser parser = new PythonParser(tokens); + parser.setTreeAdaptor(PythonGrammar.pyadaptor); + try { + Tree r = null; + switch (_block) { + case MODULE : + r = (Tree)parser.file_input().tree; + break; + case INTERACTIVE : + r = (Tree)parser.single_input().tree; + break; + case EXPRESSION : + r = (Tree)parser.eval_input().tree; + break; + } + //Tree r = (Tree)parser.file_input().tree; + if (parser.hasErrors()) { + // handle errors swallowed by antlr recovery + String errors = parser.getErrors().toString(); + if (isTolerant()) { + System.err.println(errors); + } else { + throw new RuntimeException(errors); + } + } + if (args.length > 1) { + System.out.println((r).toStringTree()); + } + if (!isParseOnly()) { + CommonTreeNodeStream nodes = new CommonTreeNodeStream(r); + nodes.setTokenStream(tokens); + PythonWalker walker = new PythonWalker(nodes); + switch (_block) { + case MODULE : + result = walker.module(); + break; + case INTERACTIVE : + result = walker.interactive(); + break; + case EXPRESSION : + result = walker.expression(); + break; + } + + if (args.length > 1) { + System.out.println(result.toStringTree()); + } + } + } catch (RecognitionException e) { + if (isTolerant()) { + System.err.println("Error: " + e); + } else { + throw e; + } + } + return result; + } + + /** + * If set to <code>true</code>, only <code>PythonParser</code> is + * called. + * + * @param parseOnly + */ + public void setParseOnly(boolean parseOnly) { + _parseOnly = parseOnly; + } + + public boolean isParseOnly() { + return _parseOnly; + } + + /** + * If set to <code>true</code>, exceptions are catched and logged to + * <code>System.err</code>. + * + * @param tolerant + */ + public void setTolerant(boolean tolerant) { + _tolerant = tolerant; + } + + public boolean isTolerant() { + return _tolerant; + } + + public void setBlock(Block block) { + _block = block; + } + + public Block getBlock() { + return _block; + } + +} Deleted: trunk/jython/src/org/python/antlr/PythonTreeWalker.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTreeWalker.java 2008-06-16 05:23:39 UTC (rev 4648) +++ trunk/jython/src/org/python/antlr/PythonTreeWalker.java 2008-06-16 13:17:01 UTC (rev 4649) @@ -1,132 +0,0 @@ -package org.python.antlr; - -import org.antlr.runtime.ANTLRFileStream; -import org.antlr.runtime.CharStream; -import org.antlr.runtime.CommonTokenStream; -import org.antlr.runtime.RecognitionException; -import org.antlr.runtime.Token; -import org.antlr.runtime.tree.CommonTreeAdaptor; -import org.antlr.runtime.tree.CommonTreeNodeStream; -import org.antlr.runtime.tree.Tree; -import org.antlr.runtime.tree.TreeAdaptor; - -/** - * A walker producing a <code>PythonTree</code> AST. - */ -public class PythonTreeWalker { - - public enum Block { MODULE, INTERACTIVE, EXPRESSION }; - - private boolean _parseOnly; - private boolean _tolerant; - private Block _block; - - public PythonTreeWalker() { - setParseOnly(false); - setTolerant(true); - setBlock(Block.MODULE); - } - - public PythonTree parse(String[] args) throws Exception { - PythonTree result = null; - CharStream input = new ANTLRFileStream(args[0]); - PythonLexer lexer = new PythonGrammar.PyLexer(input); - CommonTokenStream tokens = new CommonTokenStream(lexer); - tokens.discardOffChannelTokens(true); - PythonTokenSource indentedSource = new PythonTokenSource(tokens); - tokens = new CommonTokenStream(indentedSource); - PythonParser parser = new PythonParser(tokens); - parser.setTreeAdaptor(PythonGrammar.pyadaptor); - try { - Tree r = null; - switch (_block) { - case MODULE : - r = (Tree)parser.file_input().tree; - break; - case INTERACTIVE : - r = (Tree)parser.single_input().tree; - break; - case EXPRESSION : - r = (Tree)parser.eval_input().tree; - break; - } - //Tree r = (Tree)parser.file_input().tree; - if (parser.hasErrors()) { - // handle errors swallowed by antlr recovery - String errors = parser.getErrors().toString(); - if (isTolerant()) { - System.err.println(errors); - } else { - throw new RuntimeException(errors); - } - } - if (args.length > 1) { - System.out.println((r).toStringTree()); - } - if (!isParseOnly()) { - CommonTreeNodeStream nodes = new CommonTreeNodeStream(r); - nodes.setTokenStream(tokens); - PythonWalker walker = new PythonWalker(nodes); - switch (_block) { - case MODULE : - result = walker.module(); - break; - case INTERACTIVE : - result = walker.interactive(); - break; - case EXPRESSION : - result = walker.expression(); - break; - } - - if (args.length > 1) { - System.out.println(result.toStringTree()); - } - } - } catch (RecognitionException e) { - if (isTolerant()) { - System.err.println("Error: " + e); - } else { - throw e; - } - } - return result; - } - - /** - * If set to <code>true</code>, only <code>PythonParser</code> is - * called. - * - * @param parseOnly - */ - public void setParseOnly(boolean parseOnly) { - _parseOnly = parseOnly; - } - - public boolean isParseOnly() { - return _parseOnly; - } - - /** - * If set to <code>true</code>, exceptions are catched and logged to - * <code>System.err</code>. - * - * @param tolerant - */ - public void setTolerant(boolean tolerant) { - _tolerant = tolerant; - } - - public boolean isTolerant() { - return _tolerant; - } - - public void setBlock(Block block) { - _block = block; - } - - public Block getBlock() { - return _block; - } - -} Copied: trunk/jython/src/org/python/antlr/WalkerTester.java (from rev 4648, trunk/jython/src/org/python/antlr/Main.java) =================================================================== --- trunk/jython/src/org/python/antlr/WalkerTester.java (rev 0) +++ trunk/jython/src/org/python/antlr/WalkerTester.java 2008-06-16 13:17:01 UTC (rev 4649) @@ -0,0 +1,12 @@ +package org.python.antlr; + +public class WalkerTester extends PythonTreeTester { + + public static void main(String[] args) throws Exception { + PythonTreeTester walker = new PythonTreeTester(); + walker.setTolerant(true); + walker.setParseOnly(false); + walker.parse(args); + } + +} Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2008-06-16 05:23:39 UTC (rev 4648) +++ trunk/jython/src/org/python/core/PyString.java 2008-06-16 13:17:01 UTC (rev 4649) @@ -6,6 +6,7 @@ import org.python.core.util.ExtraMath; import org.python.core.util.StringUtil; +import org.python.expose.ExposedGet; import org.python.expose.ExposedMethod; import org.python.expose.ExposedNew; import org.python.expose.ExposedType; @@ -22,6 +23,11 @@ private transient int cached_hashcode=0; protected transient boolean interned=false; + @ExposedGet(name = "__doc__") + public PyObject getDoc() { + return new PyString("FOO"); + } + // for PyJavaClass.init() public PyString() { this(TYPE, ""); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-06-20 08:29:26
|
Revision: 4700 http://jython.svn.sourceforge.net/jython/?rev=4700&view=rev Author: pjenvey Date: 2008-06-20 01:29:23 -0700 (Fri, 20 Jun 2008) Log Message: ----------- allow deriveds __long__ to return a PyInteger Modified Paths: -------------- trunk/jython/src/org/python/core/PyArrayDerived.java trunk/jython/src/org/python/core/PyBooleanDerived.java trunk/jython/src/org/python/core/PyClassMethodDerived.java trunk/jython/src/org/python/core/PyComplexDerived.java trunk/jython/src/org/python/core/PyDictionaryDerived.java trunk/jython/src/org/python/core/PyFileDerived.java trunk/jython/src/org/python/core/PyFloatDerived.java trunk/jython/src/org/python/core/PyFrozenSetDerived.java trunk/jython/src/org/python/core/PyIntegerDerived.java trunk/jython/src/org/python/core/PyListDerived.java trunk/jython/src/org/python/core/PyLongDerived.java trunk/jython/src/org/python/core/PyModuleDerived.java trunk/jython/src/org/python/core/PyObjectDerived.java trunk/jython/src/org/python/core/PyPropertyDerived.java trunk/jython/src/org/python/core/PySetDerived.java trunk/jython/src/org/python/core/PySliceDerived.java trunk/jython/src/org/python/core/PyStringDerived.java trunk/jython/src/org/python/core/PySuperDerived.java trunk/jython/src/org/python/core/PyTupleDerived.java trunk/jython/src/org/python/core/PyTypeDerived.java trunk/jython/src/org/python/core/PyUnicodeDerived.java trunk/jython/src/org/python/modules/_weakref/ReferenceTypeDerived.java trunk/jython/src/org/python/modules/collections/PyDefaultDictDerived.java trunk/jython/src/org/python/modules/collections/PyDequeDerived.java trunk/jython/src/org/python/modules/random/PyRandomDerived.java trunk/jython/src/org/python/modules/thread/PyLocalDerived.java trunk/jython/src/org/python/modules/zipimport/zipimporterDerived.java Modified: trunk/jython/src/org/python/core/PyArrayDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyArrayDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyArrayDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PyBooleanDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyBooleanDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyBooleanDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PyClassMethodDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyClassMethodDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyClassMethodDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PyComplexDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyComplexDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyComplexDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PyDictionaryDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyDictionaryDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyDictionaryDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PyFileDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyFileDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyFileDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PyFloatDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyFloatDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyFloatDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PyFrozenSetDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyFrozenSetDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyFrozenSetDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PyIntegerDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyIntegerDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyIntegerDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PyListDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyListDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyListDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PyLongDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyLongDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyLongDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PyModuleDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyModuleDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyModuleDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -78,18 +78,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -654,6 +642,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PyObjectDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyObjectDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyObjectDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PyPropertyDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyPropertyDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyPropertyDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PySetDerived.java =================================================================== --- trunk/jython/src/org/python/core/PySetDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PySetDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PySliceDerived.java =================================================================== --- trunk/jython/src/org/python/core/PySliceDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PySliceDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PyStringDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyStringDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyStringDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PySuperDerived.java =================================================================== --- trunk/jython/src/org/python/core/PySuperDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PySuperDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PyTupleDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyTupleDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyTupleDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PyTypeDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyTypeDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyTypeDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -78,18 +78,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -654,6 +642,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/core/PyUnicodeDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyUnicodeDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/core/PyUnicodeDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -102,18 +102,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -678,6 +666,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/modules/_weakref/ReferenceTypeDerived.java =================================================================== --- trunk/jython/src/org/python/modules/_weakref/ReferenceTypeDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/modules/_weakref/ReferenceTypeDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -104,18 +104,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -680,6 +668,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/modules/collections/PyDefaultDictDerived.java =================================================================== --- trunk/jython/src/org/python/modules/collections/PyDefaultDictDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/modules/collections/PyDefaultDictDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -104,18 +104,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -680,6 +668,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/modules/collections/PyDequeDerived.java =================================================================== --- trunk/jython/src/org/python/modules/collections/PyDequeDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/modules/collections/PyDequeDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -104,18 +104,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -680,6 +668,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/modules/random/PyRandomDerived.java =================================================================== --- trunk/jython/src/org/python/modules/random/PyRandomDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/modules/random/PyRandomDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -104,18 +104,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -680,6 +668,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/modules/thread/PyLocalDerived.java =================================================================== --- trunk/jython/src/org/python/modules/thread/PyLocalDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/modules/thread/PyLocalDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -80,18 +80,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -656,6 +644,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); Modified: trunk/jython/src/org/python/modules/zipimport/zipimporterDerived.java =================================================================== --- trunk/jython/src/org/python/modules/zipimport/zipimporterDerived.java 2008-06-20 08:28:26 UTC (rev 4699) +++ trunk/jython/src/org/python/modules/zipimport/zipimporterDerived.java 2008-06-20 08:29:23 UTC (rev 4700) @@ -80,18 +80,6 @@ return super.__float__(); } - public PyLong __long__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__long__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyLong) - return(PyLong)res; - throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); - } - return super.__long__(); - } - public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); @@ -656,6 +644,18 @@ return super.__int__(); } + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + public int hashCode() { PyType self_type=getType(); PyObject impl=self_type.lookup("__hash__"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |