You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(107) |
Dec
(67) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(76) |
Feb
(125) |
Mar
(72) |
Apr
(13) |
May
(18) |
Jun
(12) |
Jul
(129) |
Aug
(47) |
Sep
(1) |
Oct
(36) |
Nov
(128) |
Dec
(124) |
2002 |
Jan
(59) |
Feb
|
Mar
(14) |
Apr
(14) |
May
(72) |
Jun
(9) |
Jul
(3) |
Aug
(5) |
Sep
(18) |
Oct
(65) |
Nov
(28) |
Dec
(12) |
2003 |
Jan
(10) |
Feb
(2) |
Mar
(4) |
Apr
(33) |
May
(21) |
Jun
(9) |
Jul
(29) |
Aug
(34) |
Sep
(4) |
Oct
(8) |
Nov
(15) |
Dec
(4) |
2004 |
Jan
(26) |
Feb
(12) |
Mar
(11) |
Apr
(9) |
May
(7) |
Jun
|
Jul
(5) |
Aug
|
Sep
(3) |
Oct
(7) |
Nov
(1) |
Dec
(10) |
2005 |
Jan
(2) |
Feb
(72) |
Mar
(16) |
Apr
(39) |
May
(48) |
Jun
(97) |
Jul
(57) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(100) |
Dec
(24) |
2006 |
Jan
(15) |
Feb
(34) |
Mar
(33) |
Apr
(31) |
May
(79) |
Jun
(64) |
Jul
(41) |
Aug
(64) |
Sep
(31) |
Oct
(46) |
Nov
(55) |
Dec
(37) |
2007 |
Jan
(32) |
Feb
(61) |
Mar
(11) |
Apr
(58) |
May
(46) |
Jun
(30) |
Jul
(94) |
Aug
(93) |
Sep
(86) |
Oct
(69) |
Nov
(125) |
Dec
(177) |
2008 |
Jan
(169) |
Feb
(97) |
Mar
(74) |
Apr
(113) |
May
(120) |
Jun
(334) |
Jul
(215) |
Aug
(237) |
Sep
(72) |
Oct
(189) |
Nov
(126) |
Dec
(160) |
2009 |
Jan
(180) |
Feb
(45) |
Mar
(98) |
Apr
(140) |
May
(151) |
Jun
(71) |
Jul
(107) |
Aug
(119) |
Sep
(73) |
Oct
(121) |
Nov
(14) |
Dec
(6) |
2010 |
Jan
(13) |
Feb
(9) |
Mar
(10) |
Apr
(64) |
May
(3) |
Jun
(16) |
Jul
(7) |
Aug
(23) |
Sep
(17) |
Oct
(37) |
Nov
(5) |
Dec
(8) |
2011 |
Jan
(10) |
Feb
(11) |
Mar
(77) |
Apr
(11) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <fwi...@us...> - 2009-01-07 23:57:43
|
Revision: 5871 http://jython.svn.sourceforge.net/jython/?rev=5871&view=rev Author: fwierzbicki Date: 2009-01-07 23:57:33 +0000 (Wed, 07 Jan 2009) Log Message: ----------- update grammar comments. Modified Paths: -------------- branches/jy3k/grammar/Python.g Modified: branches/jy3k/grammar/Python.g =================================================================== --- branches/jy3k/grammar/Python.g 2009-01-07 21:21:48 UTC (rev 5870) +++ branches/jy3k/grammar/Python.g 2009-01-07 23:57:33 UTC (rev 5871) @@ -430,7 +430,10 @@ } ; -//funcdef: [decorators] 'def' NAME parameters ':' suite +//XXX: maybe see if we can factor decorators out like this... +//decorated: decorators (classdef | funcdef) + +//funcdef: 'def' NAME parameters ['->' test] ':' suite funcdef @init { stmt stype = null; } @after { $funcdef.tree = stype; } @@ -741,7 +744,7 @@ } ; -//import_as_name: NAME [('as' | NAME) NAME] +//import_as_name: NAME ['as' NAME] import_as_name returns [alias atype] @after { $import_as_name.tree = $atype; @@ -795,7 +798,7 @@ -> ^(ASSERT<Assert>[$ASSERT, actions.castExpr($t1.tree), actions.castExpr($t2.tree)]) ; -//compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef +//compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated compound_stmt : if_stmt | while_stmt This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-07 21:21:54
|
Revision: 5870 http://jython.svn.sourceforge.net/jython/?rev=5870&view=rev Author: fwierzbicki Date: 2009-01-07 21:21:48 +0000 (Wed, 07 Jan 2009) Log Message: ----------- Use new arg node in function defs. Modified Paths: -------------- branches/jy3k/grammar/Python.g branches/jy3k/src/org/python/antlr/ErrorHandler.java branches/jy3k/src/org/python/antlr/FailFastHandler.java branches/jy3k/src/org/python/antlr/GrammarActions.java branches/jy3k/src/org/python/antlr/ListErrorHandler.java branches/jy3k/src/org/python/compiler/ArgListCompiler.java Added Paths: ----------- branches/jy3k/src/org/python/antlr/ast/ErrorArg.java Modified: branches/jy3k/grammar/Python.g =================================================================== --- branches/jy3k/grammar/Python.g 2009-01-07 18:12:46 UTC (rev 5869) +++ branches/jy3k/grammar/Python.g 2009-01-07 21:21:48 UTC (rev 5870) @@ -455,20 +455,21 @@ ; //not in CPython's Grammar file -tdefparameter[List defaults] returns [expr etype] +tdefparameter[List defaults] returns [arg etype] @after { $tdefparameter.tree = $etype; } - : vfpdef[expr_contextType.Param] (ASSIGN test[expr_contextType.Load])? + : tfpdef[expr_contextType.Param] (ASSIGN test[expr_contextType.Load])? { - $etype = actions.castExpr($vfpdef.tree); + $etype = actions.castArg($tfpdef.tree); if ($ASSIGN != null) { defaults.add($test.tree); } else if (!defaults.isEmpty()) { - throw new ParseException("non-default argument follows default argument", $vfpdef.tree); + throw new ParseException("non-default argument follows default argument", $tfpdef.tree); } } ; + //typedargslist: ((tfpdef ['=' test] ',')* // ('*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef) // | tfpdef ['=' test] (',' tfpdef ['=' test])* [',']) @@ -497,11 +498,8 @@ //tfpdef: NAME [':' test] tfpdef[expr_contextType ctype] -@after { - actions.checkAssign(actions.castExpr($tfpdef.tree)); -} - : NAME (':' test[ctype])? - -> ^(NAME<Name>[$NAME, $NAME.text, ctype]) + : NAME (COLON test[ctype])? + -> ^(NAME<arg>[$NAME, $NAME.text, null]) ; //not in CPython's Grammar file Modified: branches/jy3k/src/org/python/antlr/ErrorHandler.java =================================================================== --- branches/jy3k/src/org/python/antlr/ErrorHandler.java 2009-01-07 18:12:46 UTC (rev 5869) +++ branches/jy3k/src/org/python/antlr/ErrorHandler.java 2009-01-07 21:21:48 UTC (rev 5870) @@ -5,6 +5,7 @@ import org.antlr.runtime.IntStream; import org.antlr.runtime.Lexer; import org.antlr.runtime.RecognitionException; +import org.python.antlr.ast.arg; import org.python.antlr.base.expr; import org.python.antlr.base.mod; import org.python.antlr.base.slice; @@ -27,11 +28,12 @@ Object recoverFromMismatchedToken(BaseRecognizer br, IntStream input, int ttype, BitSet follow) throws RecognitionException; - //expr, mod, slice, stmt + //expr, mod, slice, stmt, arg expr errorExpr(PythonTree t); mod errorMod(PythonTree t); slice errorSlice(PythonTree t); stmt errorStmt(PythonTree t); + arg errorArg(PythonTree t); //exceptions void error(String message, PythonTree t); Modified: branches/jy3k/src/org/python/antlr/FailFastHandler.java =================================================================== --- branches/jy3k/src/org/python/antlr/FailFastHandler.java 2009-01-07 18:12:46 UTC (rev 5869) +++ branches/jy3k/src/org/python/antlr/FailFastHandler.java 2009-01-07 21:21:48 UTC (rev 5870) @@ -6,6 +6,7 @@ import org.antlr.runtime.Lexer; import org.antlr.runtime.MismatchedTokenException; import org.antlr.runtime.RecognitionException; +import org.python.antlr.ast.arg; import org.python.antlr.base.expr; import org.python.antlr.base.mod; import org.python.antlr.base.slice; @@ -52,6 +53,10 @@ throw new ParseException("Bad Stmt Node", t); } + public arg errorArg(PythonTree t) { + throw new ParseException("Bad Arg Node", t); + } + public void error(String message, PythonTree t) { throw new ParseException(message, t); } Modified: branches/jy3k/src/org/python/antlr/GrammarActions.java =================================================================== --- branches/jy3k/src/org/python/antlr/GrammarActions.java 2009-01-07 18:12:46 UTC (rev 5869) +++ branches/jy3k/src/org/python/antlr/GrammarActions.java 2009-01-07 21:21:48 UTC (rev 5870) @@ -156,13 +156,22 @@ List<arg> result = new ArrayList<arg>(); if (args != null) { for (Object o : args) { - if (o instanceof arg) { - result.add((arg)o); - } + result.add(castArg(o)); } } return result; } + + arg castArg(Object o) { + if (o instanceof arg) { + return (arg)o; + } + if (o instanceof PythonTree) { + return errorHandler.errorArg((PythonTree)o); + } + errorHandler.error("Bad Arg node", null); + return null; + } List<stmt> makeElse(List elseSuite, PythonTree elif) { if (elseSuite != null) { @@ -660,7 +669,6 @@ } void checkDelete(expr e) { - //System.out.println("trying to del " + e); if (e instanceof Call) { errorHandler.error("can't delete function call", e); } else if (e instanceof Num) { Modified: branches/jy3k/src/org/python/antlr/ListErrorHandler.java =================================================================== --- branches/jy3k/src/org/python/antlr/ListErrorHandler.java 2009-01-07 18:12:46 UTC (rev 5869) +++ branches/jy3k/src/org/python/antlr/ListErrorHandler.java 2009-01-07 21:21:48 UTC (rev 5870) @@ -5,6 +5,8 @@ import org.antlr.runtime.IntStream; import org.antlr.runtime.Lexer; import org.antlr.runtime.RecognitionException; +import org.python.antlr.ast.arg; +import org.python.antlr.ast.ErrorArg; import org.python.antlr.ast.ErrorMod; import org.python.antlr.ast.ErrorExpr; import org.python.antlr.ast.ErrorSlice; @@ -52,6 +54,10 @@ return new ErrorStmt(t); } + public arg errorArg(PythonTree t) { + return new ErrorArg(t); + } + public void error(String message, PythonTree t) { System.err.println(message); } Added: branches/jy3k/src/org/python/antlr/ast/ErrorArg.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/ErrorArg.java (rev 0) +++ branches/jy3k/src/org/python/antlr/ast/ErrorArg.java 2009-01-07 21:21:48 UTC (rev 5870) @@ -0,0 +1,38 @@ +package org.python.antlr.ast; +import org.python.antlr.PythonTree; +import org.antlr.runtime.CommonToken; +import org.antlr.runtime.Token; +import java.io.DataOutputStream; +import java.io.IOException; + +public class ErrorArg extends arg { + + public ErrorArg(PythonTree tree) { + super(tree, null, null); + } + + public String toString() { + return "ErrorArg"; + } + + public String toStringTree() { + return "ErrorArg"; + } + + public int getLineno() { + return getLine(); + } + + public int getCol_offset() { + return getCharPositionInLine(); + } + + public <R> R accept(VisitorIF<R> visitor) { + return null; + } + + public void traverse(VisitorIF visitor) throws Exception { + //no op. + } + +} Modified: branches/jy3k/src/org/python/compiler/ArgListCompiler.java =================================================================== --- branches/jy3k/src/org/python/compiler/ArgListCompiler.java 2009-01-07 18:12:46 UTC (rev 5869) +++ branches/jy3k/src/org/python/compiler/ArgListCompiler.java 2009-01-07 21:21:48 UTC (rev 5870) @@ -11,6 +11,7 @@ import org.python.antlr.ast.Name; import org.python.antlr.ast.Suite; import org.python.antlr.ast.Tuple; +import org.python.antlr.ast.arg; import org.python.antlr.ast.arguments; import org.python.antlr.ast.expr_contextType; import org.python.antlr.base.expr; @@ -47,9 +48,19 @@ return defaults; } + public Object visitArg(arg node) throws Exception { + if (fpnames.contains(node.getInternalArg())) { + throw new ParseException("duplicate argument name found: " + + node.getInternalArg(), node); + } + fpnames.add(node.getInternalArg()); + return node.getInternalArg(); + } + + public void visitArgs(arguments args) throws Exception { for (int i = 0; i < args.getInternalArgs().size(); i++) { - String name = (String) visit(args.getInternalArgs().get(i)); + String name = (String) visitArg(args.getInternalArgs().get(i)); names.add(name); } if (args.getInternalVararg() != null) { @@ -85,6 +96,7 @@ return node.getInternalId(); } + /* @Override public Object visitTuple(Tuple node) throws Exception { StringBuffer name = new StringBuffer("("); @@ -97,4 +109,5 @@ name.append(")"); return name.toString(); } + */ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-01-07 18:12:52
|
Revision: 5869 http://jython.svn.sourceforge.net/jython/?rev=5869&view=rev Author: cgroves Date: 2009-01-07 18:12:46 +0000 (Wed, 07 Jan 2009) Log Message: ----------- Use the path to the imported item as __file__, not the package path Modified Paths: -------------- trunk/jython/Lib/test/test_classpathimporter.py trunk/jython/src/org/python/core/ClasspathPyImporter.java trunk/jython/src/org/python/core/util/importer.java trunk/jython/src/org/python/modules/zipimport/zipimporter.java Modified: trunk/jython/Lib/test/test_classpathimporter.py =================================================================== --- trunk/jython/Lib/test/test_classpathimporter.py 2009-01-07 18:04:18 UTC (rev 5868) +++ trunk/jython/Lib/test/test_classpathimporter.py 2009-01-07 18:12:46 UTC (rev 5869) @@ -18,22 +18,24 @@ except KeyError: pass - def setClassLoaderAndCheck(self, jar): + def setClassLoaderAndCheck(self, jar, prefix): Thread.currentThread().contextClassLoader = test_support.make_jar_classloader(jar) import flat_in_jar self.assertEquals(flat_in_jar.value, 7) import jar_pkg + self.assertEquals(prefix + '/jar_pkg/__init__$py.class', jar_pkg.__file__) from jar_pkg import prefer_compiled + self.assertEquals(prefix + '/jar_pkg/prefer_compiled$py.class', prefer_compiled.__file__) self.assert_(prefer_compiled.compiled) self.assertRaises(NameError, __import__, 'flat_bad') self.assertRaises(NameError, __import__, 'jar_pkg.bad') def test_default_pyclasspath(self): - self.setClassLoaderAndCheck("classimport.jar") + self.setClassLoaderAndCheck("classimport.jar", "__pyclasspath__") def test_path_in_pyclasspath(self): sys.path = ['__pyclasspath__/Lib'] - self.setClassLoaderAndCheck("classimport_Lib.jar") + self.setClassLoaderAndCheck("classimport_Lib.jar", "__pyclasspath__/Lib") def test_main(): test_support.run_unittest(ClasspathImporterTestCase) Modified: trunk/jython/src/org/python/core/ClasspathPyImporter.java =================================================================== --- trunk/jython/src/org/python/core/ClasspathPyImporter.java 2009-01-07 18:04:18 UTC (rev 5868) +++ trunk/jython/src/org/python/core/ClasspathPyImporter.java 2009-01-07 18:12:46 UTC (rev 5869) @@ -110,6 +110,11 @@ } @Override + protected String makeFilePath(String fullname) { + return path + fullname.replace('.', '/'); + } + + @Override protected String makePackagePath(String fullname) { return path; } Modified: trunk/jython/src/org/python/core/util/importer.java =================================================================== --- trunk/jython/src/org/python/core/util/importer.java 2009-01-07 18:04:18 UTC (rev 5868) +++ trunk/jython/src/org/python/core/util/importer.java 2009-01-07 18:12:46 UTC (rev 5869) @@ -55,6 +55,12 @@ protected abstract String makeFilename(String fullname); /** + * Given a full module name, return the potential file path including the archive (without + * extension). + */ + protected abstract String makeFilePath(String fullname); + + /** * Returns an entry for a filename from makeFilename with a potential suffix such that this * importer can make a bundle with it, or null if fullFilename doesn't exist in this importer. */ @@ -156,7 +162,7 @@ */ protected final ModuleCodeData getModuleCode(String fullname) { String path = makeFilename(fullname); - String fullPath = makePackagePath(fullname); + String fullPath = makeFilePath(fullname); if (path.length() < 0) { return null; @@ -186,7 +192,7 @@ try { codeBytes = imp.readCode(fullname, bundle.inputStream, true); } catch (IOException ioe) { - throw Py.ImportError(ioe.getMessage() + "[path=" + fullPath + searchPath + "]"); + throw Py.ImportError(ioe.getMessage() + "[path=" + fullSearchPath + "]"); } } else { codeBytes = imp.compileSource(fullname, bundle.inputStream, fullSearchPath); Modified: trunk/jython/src/org/python/modules/zipimport/zipimporter.java =================================================================== --- trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2009-01-07 18:04:18 UTC (rev 5868) +++ trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2009-01-07 18:12:46 UTC (rev 5869) @@ -423,6 +423,11 @@ } @Override + protected String makeFilePath(String fullname) { + return makePackagePath(fullname); + } + + @Override protected PyObject makeEntry(String fullFilename) { return files.__finditem__(fullFilename); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-07 18:04:28
|
Revision: 5868 http://jython.svn.sourceforge.net/jython/?rev=5868&view=rev Author: fwierzbicki Date: 2009-01-07 18:04:18 +0000 (Wed, 07 Jan 2009) Log Message: ----------- Added ARROW. Created simple (and wrong) print() builtin for sanity checks. Added support for new octal representation. passed os.py through 2to3 converter. Modified Paths: -------------- branches/jy3k/Lib/os.py branches/jy3k/grammar/Python.g branches/jy3k/src/org/python/antlr/GrammarActions.java branches/jy3k/src/org/python/core/__builtin__.java Modified: branches/jy3k/Lib/os.py =================================================================== --- branches/jy3k/Lib/os.py 2009-01-07 17:42:04 UTC (rev 5867) +++ branches/jy3k/Lib/os.py 2009-01-07 18:04:18 UTC (rev 5868) @@ -83,7 +83,7 @@ os_name = str(java.lang.System.getProperty('os.name')) os_type = None - for type, (patterns, shell_commands) in _os_map.iteritems(): + for type, (patterns, shell_commands) in _os_map.items(): for pattern in patterns: if os_name.startswith(pattern): # determine the shell_command later, when it's needed: @@ -113,7 +113,7 @@ def getCurrentWorkingDirectory(self): return File(getcwd()) def getEnv(self): - return ['%s=%s' % (key, val) for key, val in environ.iteritems()] + return ['%s=%s' % (key, val) for key, val in environ.items()] def getInputStream(self): return getattr(java.lang.System, 'in') # XXX handle resetting def getOutputStream(self): @@ -412,7 +412,7 @@ Translate an error code to a message string. """ - if not isinstance(code, (int, long)): + if not isinstance(code, int): raise TypeError('an integer is required') constant = Errno.valueOf(code) if constant is Errno.__UNKNOWN_CONSTANT__: @@ -435,7 +435,7 @@ specified access to the path. The mode argument can be F_OK to test existence, or the inclusive-OR of R_OK, W_OK, and X_OK. """ - if not isinstance(mode, (int, long)): + if not isinstance(mode, int): raise TypeError('an integer is required') f = File(sys.getPath(path)) @@ -562,14 +562,14 @@ _time_t = Integer if Platform.IS_32_BIT else Long try: - floor = long(seconds) + floor = int(seconds) except TypeError: raise TypeError('an integer is required') if not _time_t.MIN_VALUE <= floor <= _time_t.MAX_VALUE: raise OverflowError('long int too large to convert to int') # usec can't exceed 1000000 - usec = long((seconds - floor) * 1e6) + usec = int((seconds - floor) * 1e6) if usec < 0: # If rounding gave us a negative number, truncate usec = 0 @@ -608,7 +608,7 @@ rawio = FileDescriptors.get(fd) try: rawio.truncate(length) - except Exception, e: + except Exception as e: raise IOError(errno.EBADF, strerror(errno.EBADF)) def lseek(fd, pos, how): @@ -619,7 +619,8 @@ rawio = FileDescriptors.get(fd) return _handle_oserror(rawio.seek, pos, how) -def open(filename, flag, mode=0777): +#FIXME: needs to change to mode=0o777 for 3.0 +def open(filename, flag, mode=0o777): """open(filename, flag [, mode=0777]) -> fd Open a file (for low level IO). @@ -655,7 +656,7 @@ if not File(sys.getPath(filename)).createNewFile(): raise OSError(errno.EEXIST, strerror(errno.EEXIST), filename) - except java.io.IOException, ioe: + except java.io.IOException as ioe: raise OSError(ioe) mode = '%s%s%s%s' % (reading and 'r' or '', @@ -667,7 +668,7 @@ from java.io import FileNotFoundException, RandomAccessFile try: fchannel = RandomAccessFile(sys.getPath(filename), 'rws').getChannel() - except FileNotFoundException, fnfe: + except FileNotFoundException as fnfe: if path.isdir(filename): raise OSError(errno.EISDIR, strerror(errno.EISDIR)) raise OSError(errno.ENOENT, strerror(errno.ENOENT), filename) @@ -841,7 +842,7 @@ # Note that listdir and error are globals in this module due # to earlier import-*. names = listdir(top) - except error, err: + except error as err: if onerror is not None: onerror(err) return @@ -875,7 +876,7 @@ def __init__(self, environ): UserDict.UserDict.__init__(self) data = self.data - for k, v in environ.items(): + for k, v in list(environ.items()): data[k.upper()] = v def __setitem__(self, key, item): self.data[key.upper()] = item @@ -890,7 +891,7 @@ def get(self, key, failobj=None): return self.data.get(key.upper(), failobj) def update(self, dict): - for k, v in dict.items(): + for k, v in list(dict.items()): self[k] = v def copy(self): return dict(self) @@ -1063,7 +1064,7 @@ return _posix.isatty(fileno) if not isinstance(fileno, IOBase): - print fileno + print(fileno) raise TypeError('a file descriptor is required') return fileno.isatty() Modified: branches/jy3k/grammar/Python.g =================================================================== --- branches/jy3k/grammar/Python.g 2009-01-07 17:42:04 UTC (rev 5867) +++ branches/jy3k/grammar/Python.g 2009-01-07 18:04:18 UTC (rev 5868) @@ -434,7 +434,7 @@ funcdef @init { stmt stype = null; } @after { $funcdef.tree = stype; } - : decorators? DEF NAME parameters COLON suite[false] + : decorators? DEF NAME parameters (ARROW test[expr_contextType.Load])? COLON suite[false] { Token t = $DEF; if ($decorators.start != null) { @@ -754,8 +754,7 @@ } ; -//XXX: when does CPython Grammar match "dotted_name NAME NAME"? -//dotted_as_name: dotted_name [('as' | NAME) NAME] +//dotted_as_name: dotted_name ['as' NAME] dotted_as_name returns [alias atype] @after { $dotted_as_name.tree = $atype; @@ -1569,6 +1568,8 @@ -> ^(YIELD<Yield>[$YIELD, actions.castExpr($testlist.tree)]) ; +ARROW : '->' ; + AS : 'as' ; ASSERT : 'assert' ; BREAK : 'break' ; @@ -1710,8 +1711,8 @@ INT : // Hex '0' ('x' | 'X') ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+ | // Octal - '0' ( '0' .. '7' )* - | '1'..'9' DIGITS* + '0' ('o' | 'O') ( '0' .. '7' )* + | '0'..'9' DIGITS* ; COMPLEX Modified: branches/jy3k/src/org/python/antlr/GrammarActions.java =================================================================== --- branches/jy3k/src/org/python/antlr/GrammarActions.java 2009-01-07 17:42:04 UTC (rev 5867) +++ branches/jy3k/src/org/python/antlr/GrammarActions.java 2009-01-07 18:04:18 UTC (rev 5868) @@ -362,8 +362,9 @@ if (s.startsWith("0x") || s.startsWith("0X")) { radix = 16; s = s.substring(2, s.length()); - } else if (s.startsWith("0")) { + } else if (s.startsWith("0o") || s.startsWith("0O")) { radix = 8; + s = s.substring(2, s.length()); } if (s.endsWith("L") || s.endsWith("l")) { s = s.substring(0, s.length()-1); Modified: branches/jy3k/src/org/python/core/__builtin__.java =================================================================== --- branches/jy3k/src/org/python/core/__builtin__.java 2009-01-07 17:42:04 UTC (rev 5867) +++ branches/jy3k/src/org/python/core/__builtin__.java 2009-01-07 18:04:18 UTC (rev 5868) @@ -370,6 +370,7 @@ dict.__setitem__("sorted", new SortedFunction()); dict.__setitem__("all", new AllFunction()); dict.__setitem__("any", new AnyFunction()); + dict.__setitem__("print", new PrintFunction()); } public static PyObject abs(PyObject o) { @@ -1591,3 +1592,22 @@ return PyFile.TYPE.__call__(args, kwds); } } + +class PrintFunction extends PyBuiltinFunctionNarrow { + PrintFunction() { + super("print", 1, 1, + "Prints the values to a stream, or to sys.stdout by default.\n" + + "Optional keyword arguments:\n" + + "file: a file-like object (stream); defaults to the current sys.stdout.\n" + + "sep: string inserted between values, default a space." + + "end: string appended after the last value, default a newline."); + } + + @Override + public PyObject __call__(PyObject arg) { + Py.println(arg); + return Py.None; + } +} + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2009-01-07 17:42:07
|
Revision: 5867 http://jython.svn.sourceforge.net/jython/?rev=5867&view=rev Author: otmarhumbel Date: 2009-01-07 17:42:04 +0000 (Wed, 07 Jan 2009) Log Message: ----------- fixed the first stumbling stone for issue #1208 Modified Paths: -------------- trunk/installer/src/java/org/python/util/install/JarInfo.java Modified: trunk/installer/src/java/org/python/util/install/JarInfo.java =================================================================== --- trunk/installer/src/java/org/python/util/install/JarInfo.java 2009-01-07 17:39:42 UTC (rev 5866) +++ trunk/installer/src/java/org/python/util/install/JarInfo.java 2009-01-07 17:42:04 UTC (rev 5867) @@ -112,7 +112,7 @@ // we expect an URL like: // jar:file:/C:/stuff/jython21i.jar!/org/python/util/install/JarInfo.class String urlString = URLDecoder.decode(url.toString(), "UTF-8"); - int jarSeparatorIndex = urlString.indexOf(JAR_SEPARATOR); + int jarSeparatorIndex = urlString.lastIndexOf(JAR_SEPARATOR); if (!urlString.startsWith(JAR_URL_PREFIX) || jarSeparatorIndex <= 0) { throw new InstallerException(Installation.getText(TextKeys.UNEXPECTED_URL, urlString)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2009-01-07 17:39:46
|
Revision: 5866 http://jython.svn.sourceforge.net/jython/?rev=5866&view=rev Author: otmarhumbel Date: 2009-01-07 17:39:42 +0000 (Wed, 07 Jan 2009) Log Message: ----------- small refactoring and javadoc Modified Paths: -------------- trunk/installer/src/java/org/python/util/install/driver/Autotest.java Modified: trunk/installer/src/java/org/python/util/install/driver/Autotest.java =================================================================== --- trunk/installer/src/java/org/python/util/install/driver/Autotest.java 2009-01-07 08:28:57 UTC (rev 5865) +++ trunk/installer/src/java/org/python/util/install/driver/Autotest.java 2009-01-07 17:39:42 UTC (rev 5866) @@ -30,7 +30,7 @@ */ protected Autotest(InstallerCommandLine commandLine) throws IOException, DriverException { _count++; - setName(); + buildName(); if (_rootDirectory == null) { createRootDirectory(); } @@ -161,17 +161,24 @@ // private stuff // - private void setName() { - String countAsString = ""; + /** + * build a test name containing some special characters (which will be used to create the target + * directory), and store it into <code>_name</code>. + */ + private void buildName() { + StringBuilder b = new StringBuilder(24); if (_count <= 99) { - countAsString += "0"; + b.append('0'); } if (_count <= 9) { - countAsString += "0"; + b.append('0'); } - countAsString += _count; - // explicitly use a blank in the directory name, to nail down some platform specific problems - _name = countAsString + " " + getNameSuffix() + "_"; + b.append(_count); + // explicitly use a blank, to nail down some platform specific problems + b.append(' '); + b.append(getNameSuffix()); + b.append('_'); + _name = b.toString(); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2009-01-07 08:29:02
|
Revision: 5865 http://jython.svn.sourceforge.net/jython/?rev=5865&view=rev Author: otmarhumbel Date: 2009-01-07 08:28:57 +0000 (Wed, 07 Jan 2009) Log Message: ----------- preparation for an easy rename of the jython .jar files Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2009-01-07 08:08:00 UTC (rev 5864) +++ trunk/jython/build.xml 2009-01-07 08:28:57 UTC (rev 5865) @@ -108,7 +108,7 @@ <target name="full-build" depends="full-check, install" description="a full build with svn checkout" /> <target name="needed-check" unless="full-build"> - <uptodate property="antlr.notneeded" targetfile="${dist.dir}/jython.jar"> + <uptodate property="antlr.notneeded" targetfile="${dist.dir}/${jython.dev.jar}"> <srcfiles dir="grammar" includes="*.g" /> </uptodate> </target> @@ -172,6 +172,8 @@ <!-- 64 bit Java 6 needs roughly 96m for regrtest on most platforms, but Apple's needs more --> <property name="regrtest.Xmx" value="-Xmx160m" /> + <property name="jython.dev.jar" value="jython.jar" /> + <property name="jython.deploy.jar" value="jython-complete.jar" /> </target> <target name="version-init"> @@ -504,8 +506,8 @@ <target name="jar-complete" depends="jar"> <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="extlibs/jarjar-0.7.jar"/> - <jarjar destfile="${dist.dir}/jython-complete.jar"> - <zipfileset src="${dist.dir}/jython.jar"/> + <jarjar destfile="${dist.dir}/${jython.deploy.jar}"> + <zipfileset src="${dist.dir}/${jython.dev.jar}"/> <zipfileset src="extlibs/antlr-3.1.1-runtime.jar"/> <rule pattern="org.antlr.runtime.**" result="org.python.antlr.runtime.@1"/> <zipfileset src="extlibs/asm-3.1.jar"/> @@ -545,7 +547,7 @@ <jar destfile="${dist.dir}/callbacker_test.jar"> <fileset dir="${compile.dir}" includes="org/python/tests/Callbacker*"/> </jar> - <jar destfile="${dist.dir}/jython.jar" duplicate="fail"> + <jar destfile="${dist.dir}/${jython.dev.jar}" duplicate="fail"> <nameunion> <fileset dir="${exposed.dir}"/> <fileset dir="${compile.dir}" excludes="org/python/expose/generate/**"/> @@ -714,7 +716,7 @@ <echo>building installer .jar file</echo> <jar destfile="${work.dir}/jython_installer-${jython.version.noplus}.jar" update="true"> <fileset dir="${dist.dir}"> - <exclude name="jython.jar"/> + <exclude name="${jython.dev.jar}"/> <exclude name="callbacker_test.jar"/> </fileset> <manifest> @@ -799,7 +801,7 @@ <target name="bugtest" depends="create-bugtest-config"> <java classname="org.python.util.jython" fork="true" dir="${bugtests.dir}"> <classpath> - <pathelement location="${dist.dir}/jython.jar"/> + <pathelement location="${dist.dir}/${jython.dev.jar}"/> </classpath> <jvmarg value="-Dpython.home=${dist.dir}"/> <arg value="driver.py"/> @@ -828,7 +830,7 @@ # safe to edit by hand (won't be overwritten) java_home="${jdk.home}" jython_home="${dist.dir}" -classpath="${dist.dir}/jython.jar${path.separator}classes" +classpath="${dist.dir}/${jython.dev.jar}${path.separator}classes" </echo> </target> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2009-01-07 08:08:07
|
Revision: 5864 http://jython.svn.sourceforge.net/jython/?rev=5864&view=rev Author: otmarhumbel Date: 2009-01-07 08:08:00 +0000 (Wed, 07 Jan 2009) Log Message: ----------- 1) exlude jython.jar from the installation this makes the installer autotests pass again 2) do not include the /Lib files into jython-complete.jar once issue #1214 is fixed, 'java -jar jython-complete.jar' will run for all installation types (for now, set the -Dpython.home variable if not in standalone mode) Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2009-01-07 07:35:05 UTC (rev 5863) +++ trunk/jython/build.xml 2009-01-07 08:08:00 UTC (rev 5864) @@ -518,7 +518,6 @@ <rule pattern="org.jruby.ext.posix.**" result="org.python.posix.@1"/> <zipfileset src="extlibs/constantine-0.4.jar"/> <rule pattern="com.kenai.constantine.**" result="org.python.constantine.@1"/> - <fileset dir="${dist.dir}" includes="Lib/**/*" /> <manifest> <attribute name="Main-Class" value="org.python.util.jython" /> <attribute name="Built-By" value="${user.name}" /> @@ -713,7 +712,11 @@ </fileset> </copy> <echo>building installer .jar file</echo> - <jar destfile="${work.dir}/jython_installer-${jython.version.noplus}.jar" basedir="${dist.dir}" update="true"> + <jar destfile="${work.dir}/jython_installer-${jython.version.noplus}.jar" update="true"> + <fileset dir="${dist.dir}"> + <exclude name="jython.jar"/> + <exclude name="callbacker_test.jar"/> + </fileset> <manifest> <attribute name="Main-Class" value="org.python.util.install.Installation" /> <attribute name="Built-By" value="${user.name}" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2009-01-07 07:35:09
|
Revision: 5863 http://jython.svn.sourceforge.net/jython/?rev=5863&view=rev Author: otmarhumbel Date: 2009-01-07 07:35:05 +0000 (Wed, 07 Jan 2009) Log Message: ----------- - added asm and constantine .jar files to the eclipse build path - jarjar directory is not needed any more Modified Paths: -------------- trunk/jython/.classpath trunk/jython/build.xml Modified: trunk/jython/.classpath =================================================================== --- trunk/jython/.classpath 2009-01-07 04:02:38 UTC (rev 5862) +++ trunk/jython/.classpath 2009-01-07 07:35:05 UTC (rev 5863) @@ -12,8 +12,10 @@ <classpathentry kind="lib" path="extlibs/mysql-connector-java-5.1.6.jar"/> <classpathentry kind="lib" path="extlibs/postgresql-8.3-603.jdbc4.jar"/> <classpathentry kind="lib" path="extlibs/servlet-api-2.5.jar"/> - <classpathentry kind="lib" path="build/jarjar"/> <classpathentry kind="var" path="ANT_HOME/lib/ant.jar"/> <classpathentry kind="lib" path="extlibs/antlr-3.1.1-runtime.jar"/> + <classpathentry kind="lib" path="extlibs/asm-3.1.jar"/> + <classpathentry kind="lib" path="extlibs/asm-commons-3.1.jar"/> + <classpathentry kind="lib" path="extlibs/constantine-0.4.jar"/> <classpathentry kind="output" path="bugtests/classes"/> </classpath> Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2009-01-07 04:02:38 UTC (rev 5862) +++ trunk/jython/build.xml 2009-01-07 07:35:05 UTC (rev 5863) @@ -135,7 +135,6 @@ <property name="extlibs.dir" value="${jython.base.dir}/extlibs" /> <property name="output.dir" value="${work.dir}/build" /> <property name="compile.dir" value="${output.dir}/classes" /> - <property name="jarjar.dir" value="${output.dir}/jarjar" /> <property name="exposed.dir" value="${output.dir}/exposed" /> <property name="gensrc.dir" value="${output.dir}/gensrc" /> <property name="dist.dir" value="${work.dir}/dist" /> @@ -144,7 +143,6 @@ <!-- classpaths --> <path id="main.classpath"> - <pathelement path="${jarjar.dir}" /> <pathelement path="${extlibs.dir}/libreadline-java-0.8.jar" /> <pathelement path="${extlibs.dir}/jline-0.9.94.jar" /> <pathelement path="${extlibs.dir}/servlet-api-2.5.jar" /> @@ -325,7 +323,6 @@ <!-- create output directories --> <target name ="prepare-output" depends="init,needed-check,clean-if-antlr-needed"> <mkdir dir="${compile.dir}" /> - <mkdir dir="${jarjar.dir}" /> <mkdir dir="${gensrc.dir}/org/python/antlr" /> <mkdir dir="${exposed.dir}" /> <mkdir dir="${dist.dir}" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-07 04:02:42
|
Revision: 5862 http://jython.svn.sourceforge.net/jython/?rev=5862&view=rev Author: fwierzbicki Date: 2009-01-07 04:02:38 +0000 (Wed, 07 Jan 2009) Log Message: ----------- pull py3k CPythonLib Property Changed: ---------------- branches/jy3k/ Property changes on: branches/jy3k ___________________________________________________________________ Modified: svn:externals - CPythonLib http://svn.python.org/projects/python/branches/release25-maint/Lib/ + CPythonLib http://svn.python.org/projects/python/branches/py3k/Lib/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-07 04:01:32
|
Revision: 5861 http://jython.svn.sourceforge.net/jython/?rev=5861&view=rev Author: fwierzbicki Date: 2009-01-07 04:01:27 +0000 (Wed, 07 Jan 2009) Log Message: ----------- added nonlocal Modified Paths: -------------- branches/jy3k/grammar/Python.g Modified: branches/jy3k/grammar/Python.g =================================================================== --- branches/jy3k/grammar/Python.g 2009-01-07 01:21:04 UTC (rev 5860) +++ branches/jy3k/grammar/Python.g 2009-01-07 04:01:27 UTC (rev 5861) @@ -577,14 +577,15 @@ } ; -//small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | -// import_stmt | global_stmt | assert_stmt) +//small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt | +// import_stmt | global_stmt | nonlocal_stmt | assert_stmt) small_stmt : expr_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt + | nonlocal_stmt | assert_stmt ; @@ -785,6 +786,12 @@ -> ^(GLOBAL<Global>[$GLOBAL, actions.makeNames($n)]) ; +//nonlocal_stmt: 'nonlocal' NAME (',' NAME)* +nonlocal_stmt + : NONLOCAL n+=NAME (COMMA n+=NAME)* + -> ^(NONLOCAL<Global>[$NONLOCAL, actions.makeNames($n)]) + ; + //assert_stmt: 'assert' test [',' test] assert_stmt : ASSERT t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])? @@ -897,9 +904,9 @@ } ; -//with_var: ('as' | NAME) expr +//with_var: 'as' expr with_var returns [expr etype] - : (AS | NAME) expr[expr_contextType.Store] + : AS expr[expr_contextType.Store] { $etype = actions.castExpr($expr.tree); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-07 01:21:12
|
Revision: 5860 http://jython.svn.sourceforge.net/jython/?rev=5860&view=rev Author: fwierzbicki Date: 2009-01-07 01:21:04 +0000 (Wed, 07 Jan 2009) Log Message: ----------- with is a keyword now. Modified Paths: -------------- branches/jy3k/grammar/Python.g branches/jy3k/src/org/python/compiler/CodeCompiler.java Modified: branches/jy3k/grammar/Python.g =================================================================== --- branches/jy3k/grammar/Python.g 2009-01-06 21:58:40 UTC (rev 5859) +++ branches/jy3k/grammar/Python.g 2009-01-07 01:21:04 UTC (rev 5860) @@ -444,10 +444,10 @@ } ; -//parameters: '(' [varargslist] ')' +//parameters: '(' [typedargslist] ')' parameters returns [arguments args] : LPAREN - (varargslist {$args = $varargslist.args;} + (typedargslist {$args = $typedargslist.args;} | { $args = new arguments($parameters.start, new ArrayList<arg>(), null, null, new ArrayList<arg>(), null, null, new ArrayList<expr>(), new ArrayList<expr>()); } ) @@ -578,7 +578,7 @@ ; //small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | -// import_stmt | global_stmt | exec_stmt | assert_stmt) +// import_stmt | global_stmt | assert_stmt) small_stmt : expr_stmt | del_stmt | pass_stmt @@ -1571,7 +1571,6 @@ DELETE : 'del' ; ELIF : 'elif' ; EXCEPT : 'except' ; -EXEC : 'exec' ; FINALLY : 'finally' ; FROM : 'from' ; FOR : 'for' ; Modified: branches/jy3k/src/org/python/compiler/CodeCompiler.java =================================================================== --- branches/jy3k/src/org/python/compiler/CodeCompiler.java 2009-01-06 21:58:40 UTC (rev 5859) +++ branches/jy3k/src/org/python/compiler/CodeCompiler.java 2009-01-07 01:21:04 UTC (rev 5860) @@ -2151,10 +2151,6 @@ @Override public Object visitWith(With node) throws Exception { - if (!module.getFutures().withStatementSupported()) { - throw new ParseException("'with' will become a reserved keyword in Python 2.6", node); - } - final Label label_body_start = new Label(); final Label label_body_end = new Label(); final Label label_catch = new Label(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2009-01-06 22:13:44
|
Revision: 5859 http://jython.svn.sourceforge.net/jython/?rev=5859&view=rev Author: otmarhumbel Date: 2009-01-06 21:58:40 +0000 (Tue, 06 Jan 2009) Log Message: ----------- - using ${dist.dir} for both jython.jar and jython-complete.jar - no unjar of jarjar.jar (since it does not exist any more) Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2009-01-06 20:57:41 UTC (rev 5858) +++ trunk/jython/build.xml 2009-01-06 21:58:40 UTC (rev 5859) @@ -108,7 +108,7 @@ <target name="full-build" depends="full-check, install" description="a full build with svn checkout" /> <target name="needed-check" unless="full-build"> - <uptodate property="antlr.notneeded" targetfile="${dest.dir}/jython.jar"> + <uptodate property="antlr.notneeded" targetfile="${dist.dir}/jython.jar"> <srcfiles dir="grammar" includes="*.g" /> </uptodate> </target> @@ -507,7 +507,7 @@ <target name="jar-complete" depends="jar"> <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="extlibs/jarjar-0.7.jar"/> - <jarjar destfile="${output.dir}/jython-complete.jar"> + <jarjar destfile="${dist.dir}/jython-complete.jar"> <zipfileset src="${dist.dir}/jython.jar"/> <zipfileset src="extlibs/antlr-3.1.1-runtime.jar"/> <rule pattern="org.antlr.runtime.**" result="org.python.antlr.runtime.@1"/> @@ -537,11 +537,6 @@ </section> </manifest> </jarjar> - <unjar src="${output.dir}/jarjar.jar" dest="${jarjar.dir}"> - <patternset> - <exclude name="META-INF/**"/> - </patternset> - </unjar> </target> <target name="jar" depends="compile,expose"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-06 20:57:44
|
Revision: 5858 http://jython.svn.sourceforge.net/jython/?rev=5858&view=rev Author: fwierzbicki Date: 2009-01-06 20:57:41 +0000 (Tue, 06 Jan 2009) Log Message: ----------- Making the package names point to the raw original package names in source and making the jarjar step process everything in one step so the package mangling happens on our source as well as the included jars for jython-complete.jar. Modified Paths: -------------- trunk/jython/Lib/os.py trunk/jython/build.xml trunk/jython/src/org/python/compiler/AdapterMaker.java trunk/jython/src/org/python/compiler/ClassFile.java trunk/jython/src/org/python/compiler/Code.java trunk/jython/src/org/python/compiler/CodeCompiler.java trunk/jython/src/org/python/compiler/Constant.java trunk/jython/src/org/python/compiler/Module.java trunk/jython/src/org/python/compiler/ProxyMaker.java trunk/jython/src/org/python/core/APIReader.java trunk/jython/src/org/python/core/BytecodeLoader.java trunk/jython/src/org/python/core/Py.java trunk/jython/src/org/python/core/io/FileIO.java trunk/jython/src/org/python/core/io/IOBase.java trunk/jython/src/org/python/core/io/ServerSocketIO.java trunk/jython/src/org/python/expose/generate/ClassMethodExposer.java trunk/jython/src/org/python/expose/generate/DescriptorExposer.java trunk/jython/src/org/python/expose/generate/ExposeTask.java trunk/jython/src/org/python/expose/generate/ExposedFieldFinder.java trunk/jython/src/org/python/expose/generate/ExposedMethodFinder.java trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java trunk/jython/src/org/python/expose/generate/ExposedTypeVisitor.java trunk/jython/src/org/python/expose/generate/Exposer.java trunk/jython/src/org/python/expose/generate/InstanceMethodExposer.java trunk/jython/src/org/python/expose/generate/MethodExposer.java trunk/jython/src/org/python/expose/generate/NewExposer.java trunk/jython/src/org/python/expose/generate/OverridableNewExposer.java trunk/jython/src/org/python/expose/generate/PyTypes.java trunk/jython/src/org/python/expose/generate/RestrictiveAnnotationVisitor.java trunk/jython/src/org/python/expose/generate/TypeExposer.java trunk/jython/src/org/python/modules/_py_compile.java trunk/jython/src/org/python/modules/errno.java trunk/jython/tests/java/org/python/expose/generate/DescriptorExposerTest.java trunk/jython/tests/java/org/python/expose/generate/ExposeMethodFinderTest.java trunk/jython/tests/java/org/python/expose/generate/ExposedTypeVisitorTest.java trunk/jython/tests/java/org/python/expose/generate/MethodExposerTest.java trunk/jython/tests/java/org/python/expose/generate/NewExposerTest.java trunk/jython/tests/java/org/python/expose/generate/OverridableNewExposerTest.java trunk/jython/tests/java/org/python/expose/generate/TypeExposerTest.java Modified: trunk/jython/Lib/os.py =================================================================== --- trunk/jython/Lib/os.py 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/Lib/os.py 2009-01-06 20:57:41 UTC (rev 5858) @@ -47,10 +47,14 @@ import stat as _stat import sys from java.io import File -from org.python.constantine.platform import Errno from org.python.core.io import FileDescriptors, FileIO, IOBase from org.python.core.Py import newString as asPyString +try: + from org.python.constantine.platform import Errno +except ImportError: + from com.kenai.constantine.platform import Errno + # Mapping of: os._name: [name list, shell command list] _os_map = dict(nt=[ ['Windows 95', 'Windows 98', 'Windows ME', 'Windows NT', @@ -96,7 +100,10 @@ # should *NOT* use it _name = get_os_type() -from org.python.posix import JavaPOSIX, POSIXHandler, POSIXFactory +try: + from org.python.posix import JavaPOSIX, POSIXHandler, POSIXFactory +except ImportError: + from org.jruby.ext.posix import JavaPOSIX, POSIXHandler, POSIXFactory class PythonPOSIXHandler(POSIXHandler): def error(self, error, msg): @@ -420,7 +427,10 @@ if constant.name() == constant.description(): # XXX: have constantine handle this fallback # Fake constant or just lacks a description, fallback to Linux's - from org.python.constantine.platform.linux import Errno as LinuxErrno + try: + from org.python.constantine.platform.linux import Errno as LinuxErrno + except ImportError: + from com.kenai.constantine.platform.linux import Errno as LinuxErrno constant = getattr(LinuxErrno, constant.name(), None) if not constant: return 'Unknown error: %d' % code @@ -558,7 +568,10 @@ global _time_t if _time_t is None: from java.lang import Integer, Long - from org.python.posix.util import Platform + try: + from org.python.posix import Platform + except ImportError: + from org.jruby.ext.posix.util import Platform _time_t = Integer if Platform.IS_32_BIT else Long try: Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/build.xml 2009-01-06 20:57:41 UTC (rev 5858) @@ -108,20 +108,9 @@ <target name="full-build" depends="full-check, install" description="a full build with svn checkout" /> <target name="needed-check" unless="full-build"> - <uptodate property="antlr.notneeded" targetfile="${output.dir}/jarjar.jar"> + <uptodate property="antlr.notneeded" targetfile="${dest.dir}/jython.jar"> <srcfiles dir="grammar" includes="*.g" /> </uptodate> - <!-- When antlr.notneeded isn't set, a clean is run after this, so jarjar's running depends - on both that and its own jar --> - <condition property="jarjar.notneeded"> - <and> - <isset property="antlr.notneeded"/> - <uptodate targetfile="${output.dir}/jarjar.jar"> - <srcfiles dir="extlibs" includes="*" /> - <srcfiles dir="grammar" includes="*.g" /> - </uptodate> - </and> - </condition> </target> <target name="init" depends="version-init"> @@ -166,6 +155,10 @@ <pathelement path="${extlibs.dir}/antlr-2.7.7.jar" /> <pathelement path="${extlibs.dir}/antlr-3.1.1.jar" /> <pathelement path="${extlibs.dir}/stringtemplate-3.2.jar" /> + + <pathelement path="${extlibs.dir}/asm-3.1.jar" /> + <pathelement path="${extlibs.dir}/asm-commons-3.1.jar" /> + <pathelement path="${extlibs.dir}/constantine-0.4.jar" /> </path> <available property="informix.present" classname="com.informix.jdbc.IfxDriver" classpath="${informix.jar}" /> @@ -452,7 +445,7 @@ </target> - <target name="compile" depends="init,antlr_gen,jarjar,brand-version"> + <target name="compile" depends="init,antlr_gen,brand-version"> <javac destdir="${compile.dir}" target="${jdk.target.version}" source="${jdk.source.version}" @@ -512,10 +505,12 @@ includesfile="${jython.base.dir}/CoreExposed.includes"/> </target> - <target name="jarjar" depends="init,needed-check" unless="jarjar.notneeded"> + <target name="jar-complete" depends="jar"> <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="extlibs/jarjar-0.7.jar"/> - <jarjar destfile="${output.dir}/jarjar.jar"> + <jarjar destfile="${output.dir}/jython-complete.jar"> + <zipfileset src="${dist.dir}/jython.jar"/> <zipfileset src="extlibs/antlr-3.1.1-runtime.jar"/> + <rule pattern="org.antlr.runtime.**" result="org.python.antlr.runtime.@1"/> <zipfileset src="extlibs/asm-3.1.jar"/> <zipfileset src="extlibs/asm-commons-3.1.jar"/> <zipfileset src="extlibs/asm-util-3.1.jar"/> @@ -526,6 +521,21 @@ <rule pattern="org.jruby.ext.posix.**" result="org.python.posix.@1"/> <zipfileset src="extlibs/constantine-0.4.jar"/> <rule pattern="com.kenai.constantine.**" result="org.python.constantine.@1"/> + <fileset dir="${dist.dir}" includes="Lib/**/*" /> + <manifest> + <attribute name="Main-Class" value="org.python.util.jython" /> + <attribute name="Built-By" value="${user.name}" /> + <!-- info section. ATTN: no blanks, no '.' in the names --> + <section name="Build-Info"> + <attribute name="version" value="${jython.version}" /> + <attribute name="svn-build" value="${do.checkout}" /> + <attribute name="oracle" value="${oracle.present}" /> + <attribute name="informix" value="${informix.present}" /> + <attribute name="build-compiler" value="${build.compiler}" /> + <attribute name="jdk-target-version" value="${jdk.target.version}" /> + <attribute name="debug" value="${debug}" /> + </section> + </manifest> </jarjar> <unjar src="${output.dir}/jarjar.jar" dest="${jarjar.dir}"> <patternset> @@ -534,30 +544,7 @@ </unjar> </target> - <target name="jar-complete" depends="compile,expose,jarjar"> - <jar destfile="${dist.dir}/jython-complete.jar" duplicate="preserve"> - <fileset dir="${exposed.dir}"/> - <fileset dir="${compile.dir}"/> - <fileset dir="${jarjar.dir}"> - </fileset> - <manifest> - <attribute name="Main-Class" value="org.python.util.jython" /> - <attribute name="Built-By" value="${user.name}" /> - <!-- info section. ATTN: no blanks, no '.' in the names --> - <section name="Build-Info"> - <attribute name="version" value="${jython.version}" /> - <attribute name="svn-build" value="${do.checkout}" /> - <attribute name="oracle" value="${oracle.present}" /> - <attribute name="informix" value="${informix.present}" /> - <attribute name="build-compiler" value="${build.compiler}" /> - <attribute name="jdk-target-version" value="${jdk.target.version}" /> - <attribute name="debug" value="${debug}" /> - </section> - </manifest> - </jar> - </target> - - <target name="jar" depends="compile,expose,jarjar"> + <target name="jar" depends="compile,expose"> <typedef name="nameunion" classname="org.python.util.NameUnionAntType"> <classpath> <path refid="main.classpath" /> @@ -572,9 +559,6 @@ <fileset dir="${exposed.dir}"/> <fileset dir="${compile.dir}" excludes="org/python/expose/generate/**"/> </nameunion> - <fileset dir="${jarjar.dir}"> - <include name="org/python/objectweb/asm/ClassReader.class" /> - </fileset> <manifest> <attribute name="Main-Class" value="org.python.util.jython" /> <attribute name="Built-By" value="${user.name}" /> Modified: trunk/jython/src/org/python/compiler/AdapterMaker.java =================================================================== --- trunk/jython/src/org/python/compiler/AdapterMaker.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/compiler/AdapterMaker.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -6,8 +6,8 @@ import java.lang.reflect.Method; import java.util.HashSet; -import org.python.objectweb.asm.Label; -import org.python.objectweb.asm.Opcodes; +import org.objectweb.asm.Label; +import org.objectweb.asm.Opcodes; import org.python.util.Generic; Modified: trunk/jython/src/org/python/compiler/ClassFile.java =================================================================== --- trunk/jython/src/org/python/compiler/ClassFile.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/compiler/ClassFile.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -9,11 +9,11 @@ import java.util.Collections; import java.util.List; -import org.python.objectweb.asm.AnnotationVisitor; -import org.python.objectweb.asm.ClassWriter; -import org.python.objectweb.asm.FieldVisitor; -import org.python.objectweb.asm.MethodVisitor; -import org.python.objectweb.asm.Opcodes; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.FieldVisitor; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; public class ClassFile { Modified: trunk/jython/src/org/python/compiler/Code.java =================================================================== --- trunk/jython/src/org/python/compiler/Code.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/compiler/Code.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -3,11 +3,11 @@ import java.util.BitSet; import java.util.Vector; -import org.python.objectweb.asm.AnnotationVisitor; -import org.python.objectweb.asm.Attribute; -import org.python.objectweb.asm.Label; -import org.python.objectweb.asm.MethodVisitor; -import org.python.objectweb.asm.Opcodes; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.Attribute; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; class Code implements MethodVisitor, Opcodes { MethodVisitor mv; Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -79,11 +79,11 @@ import org.python.core.PyObject; import org.python.core.PyString; import org.python.core.PyUnicode; -import org.python.objectweb.asm.ClassWriter; -import org.python.objectweb.asm.Label; -import org.python.objectweb.asm.Opcodes; -import org.python.objectweb.asm.Type; -import org.python.objectweb.asm.commons.Method; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Label; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; +import org.objectweb.asm.commons.Method; public class CodeCompiler extends Visitor implements Opcodes, ClassConstants //, PythonGrammarTreeConstants { Modified: trunk/jython/src/org/python/compiler/Constant.java =================================================================== --- trunk/jython/src/org/python/compiler/Constant.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/compiler/Constant.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -4,7 +4,7 @@ import java.io.IOException; -import org.python.objectweb.asm.Opcodes; +import org.objectweb.asm.Opcodes; abstract class Constant implements Opcodes{ public Module module; Modified: trunk/jython/src/org/python/compiler/Module.java =================================================================== --- trunk/jython/src/org/python/compiler/Module.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/compiler/Module.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -10,8 +10,8 @@ import java.util.List; import java.util.Map; -import org.python.objectweb.asm.Label; -import org.python.objectweb.asm.Opcodes; +import org.objectweb.asm.Label; +import org.objectweb.asm.Opcodes; import org.python.core.CompilerFlags; import org.python.core.Py; import org.python.core.PyException; Modified: trunk/jython/src/org/python/compiler/ProxyMaker.java =================================================================== --- trunk/jython/src/org/python/compiler/ProxyMaker.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/compiler/ProxyMaker.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -16,8 +16,8 @@ import org.python.core.PyObject; import org.python.core.PyProxy; import org.python.core.PyReflectedFunction; -import org.python.objectweb.asm.Label; -import org.python.objectweb.asm.Opcodes; +import org.objectweb.asm.Label; +import org.objectweb.asm.Opcodes; import org.python.util.Generic; public class ProxyMaker implements ClassConstants, Opcodes Modified: trunk/jython/src/org/python/core/APIReader.java =================================================================== --- trunk/jython/src/org/python/core/APIReader.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/core/APIReader.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -6,9 +6,9 @@ import java.io.IOException; -import org.python.objectweb.asm.AnnotationVisitor; -import org.python.objectweb.asm.ClassReader; -import org.python.objectweb.asm.commons.EmptyVisitor; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.commons.EmptyVisitor; /** * This class reads a classfile from a byte array and pulls out the value of the class annotation Modified: trunk/jython/src/org/python/core/BytecodeLoader.java =================================================================== --- trunk/jython/src/org/python/core/BytecodeLoader.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/core/BytecodeLoader.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -4,7 +4,7 @@ import java.security.SecureClassLoader; import java.util.List; -import org.python.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassReader; import org.python.util.Generic; /** Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/core/Py.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -20,7 +20,7 @@ import java.util.Set; import org.python.antlr.base.mod; -import org.python.constantine.platform.Errno; +import com.kenai.constantine.platform.Errno; import org.python.compiler.Module; import org.python.core.adapter.ClassicPyObjectAdapter; import org.python.core.adapter.ExtensiblePyObjectAdapter; Modified: trunk/jython/src/org/python/core/io/FileIO.java =================================================================== --- trunk/jython/src/org/python/core/io/FileIO.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/core/io/FileIO.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -12,7 +12,7 @@ import java.nio.channels.Channels; import java.nio.channels.FileChannel; -import org.python.constantine.platform.Errno; +import com.kenai.constantine.platform.Errno; import org.python.core.imp; import org.python.core.Py; import org.python.core.util.RelativeFile; Modified: trunk/jython/src/org/python/core/io/IOBase.java =================================================================== --- trunk/jython/src/org/python/core/io/IOBase.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/core/io/IOBase.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -1,7 +1,7 @@ /* Copyright (c) 2007 Jython Developers */ package org.python.core.io; -import org.python.constantine.platform.Errno; +import com.kenai.constantine.platform.Errno; import java.io.InputStream; import java.io.OutputStream; Modified: trunk/jython/src/org/python/core/io/ServerSocketIO.java =================================================================== --- trunk/jython/src/org/python/core/io/ServerSocketIO.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/core/io/ServerSocketIO.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -6,7 +6,7 @@ import java.nio.channels.Channel; import java.nio.channels.ServerSocketChannel; -import org.python.constantine.platform.Errno; +import com.kenai.constantine.platform.Errno; import org.python.core.Py; /** Modified: trunk/jython/src/org/python/expose/generate/ClassMethodExposer.java =================================================================== --- trunk/jython/src/org/python/expose/generate/ClassMethodExposer.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/expose/generate/ClassMethodExposer.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -1,6 +1,6 @@ package org.python.expose.generate; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.Type; import org.python.core.PyBuiltinClassMethodNarrow; public class ClassMethodExposer extends MethodExposer { Modified: trunk/jython/src/org/python/expose/generate/DescriptorExposer.java =================================================================== --- trunk/jython/src/org/python/expose/generate/DescriptorExposer.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/expose/generate/DescriptorExposer.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -1,6 +1,6 @@ package org.python.expose.generate; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.Type; import org.python.core.PyDataDescr; /** Modified: trunk/jython/src/org/python/expose/generate/ExposeTask.java =================================================================== --- trunk/jython/src/org/python/expose/generate/ExposeTask.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/expose/generate/ExposeTask.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -11,7 +11,7 @@ import org.apache.tools.ant.types.Path; import org.apache.tools.ant.util.GlobPatternMapper; import org.apache.tools.ant.util.SourceFileScanner; -import org.python.objectweb.asm.ClassWriter; +import org.objectweb.asm.ClassWriter; import org.python.util.Generic; public class ExposeTask extends MatchingTask { Modified: trunk/jython/src/org/python/expose/generate/ExposedFieldFinder.java =================================================================== --- trunk/jython/src/org/python/expose/generate/ExposedFieldFinder.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/expose/generate/ExposedFieldFinder.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -1,8 +1,8 @@ package org.python.expose.generate; -import org.python.objectweb.asm.AnnotationVisitor; -import org.python.objectweb.asm.Attribute; -import org.python.objectweb.asm.FieldVisitor; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.Attribute; +import org.objectweb.asm.FieldVisitor; public abstract class ExposedFieldFinder implements FieldVisitor, PyTypes { Modified: trunk/jython/src/org/python/expose/generate/ExposedMethodFinder.java =================================================================== --- trunk/jython/src/org/python/expose/generate/ExposedMethodFinder.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/expose/generate/ExposedMethodFinder.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -3,11 +3,11 @@ import java.util.List; import org.python.expose.MethodType; -import org.python.objectweb.asm.AnnotationVisitor; -import org.python.objectweb.asm.MethodAdapter; -import org.python.objectweb.asm.MethodVisitor; -import org.python.objectweb.asm.Opcodes; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.MethodAdapter; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; import org.python.util.Generic; /** Modified: trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java =================================================================== --- trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -7,16 +7,16 @@ import java.util.Map; import org.python.expose.ExposedType; -import org.python.objectweb.asm.AnnotationVisitor; -import org.python.objectweb.asm.ClassAdapter; -import org.python.objectweb.asm.ClassReader; -import org.python.objectweb.asm.ClassVisitor; -import org.python.objectweb.asm.ClassWriter; -import org.python.objectweb.asm.FieldVisitor; -import org.python.objectweb.asm.MethodAdapter; -import org.python.objectweb.asm.MethodVisitor; -import org.python.objectweb.asm.Opcodes; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.ClassAdapter; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.FieldVisitor; +import org.objectweb.asm.MethodAdapter; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; import org.python.util.Generic; /** Modified: trunk/jython/src/org/python/expose/generate/ExposedTypeVisitor.java =================================================================== --- trunk/jython/src/org/python/expose/generate/ExposedTypeVisitor.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/expose/generate/ExposedTypeVisitor.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -1,7 +1,7 @@ package org.python.expose.generate; -import org.python.objectweb.asm.AnnotationVisitor; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.Type; /** * Visits an ExposedType annotation and passes the values it gathers to handleResult. Modified: trunk/jython/src/org/python/expose/generate/Exposer.java =================================================================== --- trunk/jython/src/org/python/expose/generate/Exposer.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/expose/generate/Exposer.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -3,12 +3,12 @@ import java.util.HashMap; import java.util.Map; -import org.python.objectweb.asm.ClassVisitor; -import org.python.objectweb.asm.ClassWriter; -import org.python.objectweb.asm.Label; -import org.python.objectweb.asm.MethodVisitor; -import org.python.objectweb.asm.Opcodes; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; import org.python.core.BytecodeLoader; /** Modified: trunk/jython/src/org/python/expose/generate/InstanceMethodExposer.java =================================================================== --- trunk/jython/src/org/python/expose/generate/InstanceMethodExposer.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/expose/generate/InstanceMethodExposer.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -1,7 +1,7 @@ package org.python.expose.generate; -import org.python.objectweb.asm.Label; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.Label; +import org.objectweb.asm.Type; import org.python.core.PyBuiltinMethod; import org.python.core.PyBuiltinMethodNarrow; import org.python.expose.ExposedMethod; Modified: trunk/jython/src/org/python/expose/generate/MethodExposer.java =================================================================== --- trunk/jython/src/org/python/expose/generate/MethodExposer.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/expose/generate/MethodExposer.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -1,6 +1,6 @@ package org.python.expose.generate; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.Type; public abstract class MethodExposer extends Exposer { Modified: trunk/jython/src/org/python/expose/generate/NewExposer.java =================================================================== --- trunk/jython/src/org/python/expose/generate/NewExposer.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/expose/generate/NewExposer.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -2,8 +2,8 @@ import java.lang.reflect.Method; -import org.python.objectweb.asm.Opcodes; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; import org.python.core.PyNewWrapper; import org.python.core.PyObject; import org.python.core.PyType; Modified: trunk/jython/src/org/python/expose/generate/OverridableNewExposer.java =================================================================== --- trunk/jython/src/org/python/expose/generate/OverridableNewExposer.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/expose/generate/OverridableNewExposer.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -1,8 +1,8 @@ package org.python.expose.generate; import org.python.core.PyOverridableNew; -import org.python.objectweb.asm.Label; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.Label; +import org.objectweb.asm.Type; public class OverridableNewExposer extends Exposer { Modified: trunk/jython/src/org/python/expose/generate/PyTypes.java =================================================================== --- trunk/jython/src/org/python/expose/generate/PyTypes.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/expose/generate/PyTypes.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -1,6 +1,6 @@ package org.python.expose.generate; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.Type; import org.python.core.Py; import org.python.core.PyBoolean; import org.python.core.PyBuiltinCallable; Modified: trunk/jython/src/org/python/expose/generate/RestrictiveAnnotationVisitor.java =================================================================== --- trunk/jython/src/org/python/expose/generate/RestrictiveAnnotationVisitor.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/expose/generate/RestrictiveAnnotationVisitor.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -1,6 +1,6 @@ package org.python.expose.generate; -import org.python.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.AnnotationVisitor; /** * An Annotation visitor that throws an IllegalArgumentException if it visits anything other than Modified: trunk/jython/src/org/python/expose/generate/TypeExposer.java =================================================================== --- trunk/jython/src/org/python/expose/generate/TypeExposer.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/expose/generate/TypeExposer.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -7,7 +7,7 @@ import org.python.expose.BaseTypeBuilder; import org.python.expose.ExposedType; import org.python.expose.TypeBuilder; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.Type; import org.python.util.Generic; /** Modified: trunk/jython/src/org/python/modules/_py_compile.java =================================================================== --- trunk/jython/src/org/python/modules/_py_compile.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/modules/_py_compile.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -3,7 +3,7 @@ import java.io.File; -import org.python.constantine.platform.Errno; +import com.kenai.constantine.platform.Errno; import org.python.core.Py; import org.python.core.PyList; import org.python.core.PyString; Modified: trunk/jython/src/org/python/modules/errno.java =================================================================== --- trunk/jython/src/org/python/modules/errno.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/src/org/python/modules/errno.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -1,8 +1,8 @@ /* Copyright (c) Jython Developers */ package org.python.modules; -import org.python.constantine.Constant; -import org.python.constantine.ConstantSet; +import com.kenai.constantine.Constant; +import com.kenai.constantine.ConstantSet; import org.python.core.ClassDictInit; import org.python.core.Py; import org.python.core.PyDictionary; @@ -14,7 +14,7 @@ * The Python errno module. * * Errno constants can be accessed from Java code via - * {@link org.python.constantine.platform.Errno}, e.g. Errno.ENOENT. + * {@link com.kenai.constantine.platform.Errno}, e.g. Errno.ENOENT. */ public class errno implements ClassDictInit { Modified: trunk/jython/tests/java/org/python/expose/generate/DescriptorExposerTest.java =================================================================== --- trunk/jython/tests/java/org/python/expose/generate/DescriptorExposerTest.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/tests/java/org/python/expose/generate/DescriptorExposerTest.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -1,6 +1,6 @@ package org.python.expose.generate; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.Type; import org.python.core.BytecodeLoader; import org.python.core.Py; import org.python.core.PyDataDescr; Modified: trunk/jython/tests/java/org/python/expose/generate/ExposeMethodFinderTest.java =================================================================== --- trunk/jython/tests/java/org/python/expose/generate/ExposeMethodFinderTest.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/tests/java/org/python/expose/generate/ExposeMethodFinderTest.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -2,10 +2,10 @@ import junit.framework.TestCase; -import org.python.objectweb.asm.AnnotationVisitor; -import org.python.objectweb.asm.Opcodes; -import org.python.objectweb.asm.Type; -import org.python.objectweb.asm.commons.EmptyVisitor; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; +import org.objectweb.asm.commons.EmptyVisitor; import org.python.expose.ExposedMethod; import org.python.expose.ExposedNew; Modified: trunk/jython/tests/java/org/python/expose/generate/ExposedTypeVisitorTest.java =================================================================== --- trunk/jython/tests/java/org/python/expose/generate/ExposedTypeVisitorTest.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/tests/java/org/python/expose/generate/ExposedTypeVisitorTest.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -2,7 +2,7 @@ import junit.framework.TestCase; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.Type; import org.python.core.PyObject; import org.python.expose.generate.ExposedTypeVisitor; Modified: trunk/jython/tests/java/org/python/expose/generate/MethodExposerTest.java =================================================================== --- trunk/jython/tests/java/org/python/expose/generate/MethodExposerTest.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/tests/java/org/python/expose/generate/MethodExposerTest.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -1,7 +1,7 @@ package org.python.expose.generate; -import org.python.objectweb.asm.Opcodes; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; import org.python.core.BytecodeLoader; import org.python.core.Py; import org.python.core.PyBuiltinCallable; Modified: trunk/jython/tests/java/org/python/expose/generate/NewExposerTest.java =================================================================== --- trunk/jython/tests/java/org/python/expose/generate/NewExposerTest.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/tests/java/org/python/expose/generate/NewExposerTest.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -1,7 +1,7 @@ package org.python.expose.generate; -import org.python.objectweb.asm.Opcodes; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; import org.python.core.BytecodeLoader; import org.python.core.Py; import org.python.core.PyNewWrapper; Modified: trunk/jython/tests/java/org/python/expose/generate/OverridableNewExposerTest.java =================================================================== --- trunk/jython/tests/java/org/python/expose/generate/OverridableNewExposerTest.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/tests/java/org/python/expose/generate/OverridableNewExposerTest.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -1,7 +1,7 @@ package org.python.expose.generate; -import org.python.objectweb.asm.Opcodes; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; import org.python.core.BytecodeLoader; import org.python.core.Py; import org.python.core.PyDictionary; Modified: trunk/jython/tests/java/org/python/expose/generate/TypeExposerTest.java =================================================================== --- trunk/jython/tests/java/org/python/expose/generate/TypeExposerTest.java 2009-01-06 02:11:04 UTC (rev 5857) +++ trunk/jython/tests/java/org/python/expose/generate/TypeExposerTest.java 2009-01-06 20:57:41 UTC (rev 5858) @@ -4,7 +4,7 @@ import junit.framework.TestCase; -import org.python.objectweb.asm.Type; +import org.objectweb.asm.Type; import org.python.core.Py; import org.python.core.PyNewWrapper; import org.python.core.PyObject; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-06 02:11:06
|
Revision: 5857 http://jython.svn.sourceforge.net/jython/?rev=5857&view=rev Author: fwierzbicki Date: 2009-01-06 02:11:04 +0000 (Tue, 06 Jan 2009) Log Message: ----------- Remove some unused methods. Modified Paths: -------------- trunk/jython/src/org/python/antlr/GrammarActions.java Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2009-01-05 21:05:05 UTC (rev 5856) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2009-01-06 02:11:04 UTC (rev 5857) @@ -461,81 +461,6 @@ //return (Token)s.get(s.size() - 1); } - //FROM Walker: - mod makeMod(PythonTree t, List stmts) { - List<stmt> s = castStmts(stmts); - return new Module(t, s); - } - - mod makeExpression(PythonTree t, expr e) { - return new Expression(t, e); - } - - mod makeInteractive(PythonTree t, List stmts) { - List<stmt> s = castStmts(stmts); - return new Interactive(t, s); - } - - stmt makeClassDef(PythonTree t, PythonTree nameToken, List bases, List body, List decorators) { - if (nameToken == null) { - return errorHandler.errorStmt(t); - } - cantBeNone(nameToken); - List<expr> b = castExprs(bases); - List<stmt> s = castStmts(body); - List<expr> d = castExprs(decorators); - return new ClassDef(t, nameToken.getText(), b, s, d); - } - - stmt makeTryExcept(PythonTree t, List body, List handlers, List orelse, List finBody) { - List<stmt> b = castStmts(body); - List<excepthandler> e = handlers; - List<stmt> o = castStmts(orelse); - - stmt te = new TryExcept(t, b, e, o); - if (finBody == null) { - return te; - } - List<stmt> f = castStmts(finBody); - List<stmt> mainBody = new ArrayList<stmt>(); - mainBody.add(te); - return new TryFinally(t, mainBody, f); - } - - TryFinally makeTryFinally(PythonTree t, List body, List finBody) { - List<stmt> b = castStmts(body); - List<stmt> f = castStmts(finBody); - return new TryFinally(t, b, f); - } - - stmt makeIf(PythonTree t, expr test, List body, List orelse) { - if (test == null) { - return errorHandler.errorStmt(t); - } - List<stmt> o = castStmts(orelse); - List<stmt> b = castStmts(body); - return new If(t, test, b, o); - } - - stmt makeWhile(PythonTree t, expr test, List body, List orelse) { - if (test == null) { - return errorHandler.errorStmt(t); - } - List<stmt> o = castStmts(orelse); - List<stmt> b = castStmts(body); - return new While(t, test, b, o); - } - - stmt makeFor(PythonTree t, expr target, expr iter, List body, List orelse) { - if (target == null || iter == null) { - return errorHandler.errorStmt(t); - } - cantBeNone(target); - List<stmt> o = castStmts(orelse); - List<stmt> b = castStmts(body); - return new For(t, target, iter, b, o); - } - expr makeCall(Token t, expr func) { return makeCall(t, func, null, null, null, null); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-05 21:05:09
|
Revision: 5856 http://jython.svn.sourceforge.net/jython/?rev=5856&view=rev Author: fwierzbicki Date: 2009-01-05 21:05:05 +0000 (Mon, 05 Jan 2009) Log Message: ----------- use text instead of getText() to handle null. Modified Paths: -------------- branches/jy3k/grammar/Python.g Modified: branches/jy3k/grammar/Python.g =================================================================== --- branches/jy3k/grammar/Python.g 2009-01-05 19:58:51 UTC (rev 5855) +++ branches/jy3k/grammar/Python.g 2009-01-05 21:05:05 UTC (rev 5856) @@ -908,7 +908,7 @@ //except_clause: 'except' [test ['as' NAME]] except_clause : EXCEPT (test[expr_contextType.Load] (AS NAME)?)? COLON suite[!$suite.isEmpty() && $suite::continueIllegal] - -> ^(EXCEPT<ExceptHandler>[$EXCEPT, actions.castExpr($test.tree), $NAME.getText(), + -> ^(EXCEPT<ExceptHandler>[$EXCEPT, actions.castExpr($test.tree), $NAME.text, actions.castStmts($suite.stypes)]) ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <am...@us...> - 2009-01-05 19:58:55
|
Revision: 5855 http://jython.svn.sourceforge.net/jython/?rev=5855&view=rev Author: amak Date: 2009-01-05 19:58:51 +0000 (Mon, 05 Jan 2009) Log Message: ----------- Fixed a bug where connect timeouts were not being honoured when set through socket.setdefaulttimeout() http://bugs.jython.org/issue1218 Modified Paths: -------------- branches/Release_2_2maint/jython/Lib/socket.py branches/Release_2_2maint/jython/Lib/test/test_socket.py Modified: branches/Release_2_2maint/jython/Lib/socket.py =================================================================== --- branches/Release_2_2maint/jython/Lib/socket.py 2009-01-05 19:47:25 UTC (rev 5854) +++ branches/Release_2_2maint/jython/Lib/socket.py 2009-01-05 19:58:51 UTC (rev 5855) @@ -617,12 +617,14 @@ class _nonblocking_api_mixin: - timeout = _defaulttimeout mode = MODE_BLOCKING reference_count = 0 close_lock = threading.Lock() def __init__(self): + self.timeout = _defaulttimeout + if self.timeout is not None: + self.mode = MODE_TIMEOUT self.pending_options = { SO_REUSEADDR: 0, } Modified: branches/Release_2_2maint/jython/Lib/test/test_socket.py =================================================================== --- branches/Release_2_2maint/jython/Lib/test/test_socket.py 2009-01-05 19:47:25 UTC (rev 5854) +++ branches/Release_2_2maint/jython/Lib/test/test_socket.py 2009-01-05 19:58:51 UTC (rev 5855) @@ -1295,6 +1295,23 @@ socket.timeout. This tries to connect to %s in the assumption that it isn't used, but if it is on your network this failure is bogus.''' % host) + def testConnectDefaultTimeout(self): + _saved_timeout = socket.getdefaulttimeout() + socket.setdefaulttimeout(0.1) + cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + host = '192.168.192.168' + try: + cli.connect((host, 5000)) + except socket.timeout, st: + pass + except Exception, x: + self.fail("Client socket timeout should have raised socket.timeout, not %s" % str(x)) + else: + self.fail('''Client socket timeout should have raised +socket.timeout. This tries to connect to %s in the assumption that it isn't +used, but if it is on your network this failure is bogus.''' % host) + socket.setdefaulttimeout(_saved_timeout) + def testRecvTimeout(self): def raise_timeout(*args, **kwargs): cli_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <am...@us...> - 2009-01-05 19:47:31
|
Revision: 5854 http://jython.svn.sourceforge.net/jython/?rev=5854&view=rev Author: amak Date: 2009-01-05 19:47:25 +0000 (Mon, 05 Jan 2009) Log Message: ----------- Fixed a bug where connect timeouts were not being honoured when set through socket.setdefaulttimeout() http://bugs.jython.org/issue1218 Modified Paths: -------------- trunk/jython/Lib/socket.py trunk/jython/Lib/test/test_socket.py Modified: trunk/jython/Lib/socket.py =================================================================== --- trunk/jython/Lib/socket.py 2009-01-05 19:06:58 UTC (rev 5853) +++ trunk/jython/Lib/socket.py 2009-01-05 19:47:25 UTC (rev 5854) @@ -632,12 +632,14 @@ class _nonblocking_api_mixin: - timeout = _defaulttimeout mode = MODE_BLOCKING reference_count = 0 close_lock = threading.Lock() def __init__(self): + self.timeout = _defaulttimeout + if self.timeout is not None: + self.mode = MODE_TIMEOUT self.pending_options = { SO_REUSEADDR: 0, } @@ -791,7 +793,7 @@ self.sock_impl.bind(bind_host, bind_port, self.pending_options[SO_REUSEADDR]) self._config() # Configure timeouts, etc, now that the socket exists self.sock_impl.connect(host, port) - except java.lang.Exception, jlx: + except java.lang.Exception, jlx: raise _map_exception(jlx) def connect(self, addr): Modified: trunk/jython/Lib/test/test_socket.py =================================================================== --- trunk/jython/Lib/test/test_socket.py 2009-01-05 19:06:58 UTC (rev 5853) +++ trunk/jython/Lib/test/test_socket.py 2009-01-05 19:47:25 UTC (rev 5854) @@ -1320,6 +1320,23 @@ socket.timeout. This tries to connect to %s in the assumption that it isn't used, but if it is on your network this failure is bogus.''' % host) + def testConnectDefaultTimeout(self): + _saved_timeout = socket.getdefaulttimeout() + socket.setdefaulttimeout(0.1) + cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + host = '192.168.192.168' + try: + cli.connect((host, 5000)) + except socket.timeout, st: + pass + except Exception, x: + self.fail("Client socket timeout should have raised socket.timeout, not %s" % str(x)) + else: + self.fail('''Client socket timeout should have raised +socket.timeout. This tries to connect to %s in the assumption that it isn't +used, but if it is on your network this failure is bogus.''' % host) + socket.setdefaulttimeout(_saved_timeout) + def testRecvTimeout(self): def raise_timeout(*args, **kwargs): cli_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-05 19:07:03
|
Revision: 5853 http://jython.svn.sourceforge.net/jython/?rev=5853&view=rev Author: fwierzbicki Date: 2009-01-05 19:06:58 +0000 (Mon, 05 Jan 2009) Log Message: ----------- Merged with py3k site.py Modified Paths: -------------- branches/jy3k/Lib/site.py Modified: branches/jy3k/Lib/site.py =================================================================== --- branches/jy3k/Lib/site.py 2009-01-05 18:48:54 UTC (rev 5852) +++ branches/jy3k/Lib/site.py 2009-01-05 19:06:58 UTC (rev 5853) @@ -4,12 +4,6 @@ * This module is automatically imported during initialization. * **************************************************************** -In earlier versions of Python (up to 1.5a3), scripts or modules that -needed to use site-specific modules would place ``import site'' -somewhere near the top of their code. Because of the automatic -import, this is no longer necessary (but code that does it still -works). - This will append site-specific paths to the module search path. On Unix (including Mac OSX), it starts with sys.prefix and sys.exec_prefix (if different) and appends @@ -60,9 +54,18 @@ import sys import os -import __builtin__ +import builtins +# Prefixes for site-packages; add additional prefixes like /usr/local here +PREFIXES = [sys.prefix, sys.exec_prefix] +# Enable per user site-packages directory +# set it to False to disable the feature or True to force the feature +ENABLE_USER_SITE = None +# for distutils.commands.install +USER_SITE = None +USER_BASE = None + def makepath(*paths): dir = os.path.join(*paths) if dir == '__classpath__' or dir.startswith('__pyclasspath__'): @@ -72,7 +75,7 @@ def abs__file__(): """Set all module' __file__ attribute to an absolute path""" - for m in sys.modules.values(): + for m in set(sys.modules.values()): if hasattr(m, '__loader__'): continue # don't mess with a PEP 302-supplied __file__ f = getattr(m, '__file__', None) @@ -105,9 +108,12 @@ (especially for Guido :-)""" from distutils.util import get_platform s = "build/lib.%s-%.3s" % (get_platform(), sys.version) + if hasattr(sys, 'gettotalrefcount'): + s += '-pydebug' s = os.path.join(os.path.dirname(sys.path[-1]), s) sys.path.append(s) + def _init_pathinfo(): """Return a set containing all existing directory entries from sys.path""" d = set() @@ -120,9 +126,12 @@ continue return d + def addpackage(sitedir, name, known_paths): - """Add a new path to known_paths by combining sitedir and 'name' or execute - sitedir if it starts with 'import'""" + """Process a .pth file within the site-packages directory: + For each line in the file, either combine it with sitedir to a path + and add that to known_paths, or execute it if it starts with 'import '. + """ if known_paths is None: _init_pathinfo() reset = 1 @@ -133,24 +142,23 @@ f = open(fullname, "rU") except IOError: return - try: + with f: for line in f: if line.startswith("#"): continue - if line.startswith("import"): - exec line + if line.startswith(("import ", "import\t")): + exec(line) continue line = line.rstrip() dir, dircase = makepath(sitedir, line) if not dircase in known_paths and os.path.exists(dir): sys.path.append(dir) known_paths.add(dircase) - finally: - f.close() if reset: known_paths = None return known_paths + def addsitedir(sitedir, known_paths=None): """Add 'sitedir' argument to sys.path if missing and handle .pth files in 'sitedir'""" @@ -166,50 +174,116 @@ names = os.listdir(sitedir) except os.error: return - names.sort() - for name in names: - if name.endswith(os.extsep + "pth"): - addpackage(sitedir, name, known_paths) + names = [name for name in names if name.endswith(".pth")] + for name in sorted(names): + addpackage(sitedir, name, known_paths) if reset: known_paths = None return known_paths + +def check_enableusersite(): + """Check if user site directory is safe for inclusion + + The function tests for the command line flag (including environment var), + process uid/gid equal to effective uid/gid. + + None: Disabled for security reasons + False: Disabled by user (command line option) + True: Safe and enabled + """ + if sys.flags.no_user_site: + return False + + if hasattr(os, "getuid") and hasattr(os, "geteuid"): + # check process uid == effective uid + if os.geteuid() != os.getuid(): + return None + if hasattr(os, "getgid") and hasattr(os, "getegid"): + # check process gid == effective gid + if os.getegid() != os.getgid(): + return None + + return True + + +def addusersitepackages(known_paths): + """Add a per user site-package to sys.path + + Each user has its own python directory with site-packages in the + home directory. + + USER_BASE is the root directory for all Python versions + + USER_SITE is the user specific site-packages directory + + USER_SITE/.. can be used for data. + """ + global USER_BASE, USER_SITE, ENABLE_USER_SITE + env_base = os.environ.get("PYTHONUSERBASE", None) + + def joinuser(*args): + return os.path.expanduser(os.path.join(*args)) + + #if sys.platform in ('os2emx', 'riscos'): + # # Don't know what to put here + # USER_BASE = '' + # USER_SITE = '' + if os.name == "nt": + base = os.environ.get("APPDATA") or "~" + USER_BASE = env_base if env_base else joinuser(base, "Python") + USER_SITE = os.path.join(USER_BASE, + "Python" + sys.version[0] + sys.version[2], + "site-packages") + else: + USER_BASE = env_base if env_base else joinuser("~", ".local") + USER_SITE = os.path.join(USER_BASE, "lib", + "python" + sys.version[:3], + "site-packages") + + if ENABLE_USER_SITE and os.path.isdir(USER_SITE): + addsitedir(USER_SITE, known_paths) + return known_paths + + def addsitepackages(known_paths): """Add site-packages (and possibly site-python) to sys.path""" - prefixes = [sys.prefix] - if sys.exec_prefix != sys.prefix: - prefixes.append(sys.exec_prefix) - for prefix in prefixes: - if prefix: - if sys.platform in ('os2emx', 'riscos') or sys.platform[:4] == 'java': - sitedirs = [os.path.join(prefix, "Lib", "site-packages")] - elif os.sep == '/': - sitedirs = [os.path.join(prefix, - "lib", - "python" + sys.version[:3], - "site-packages"), - os.path.join(prefix, "lib", "site-python")] - else: - sitedirs = [prefix, os.path.join(prefix, "lib", "site-packages")] - if sys.platform == 'darwin': - # for framework builds *only* we add the standard Apple - # locations. Currently only per-user, but /Library and - # /Network/Library could be added too - if 'Python.framework' in prefix: - home = os.environ.get('HOME') - if home: - sitedirs.append( - os.path.join(home, - 'Library', - 'Python', - sys.version[:3], - 'site-packages')) - for sitedir in sitedirs: - if os.path.isdir(sitedir): - addsitedir(sitedir, known_paths) - return None + sitedirs = [] + seen = [] + for prefix in PREFIXES: + if not prefix or prefix in seen: + continue + seen.append(prefix) + if sys.platform in ('os2emx', 'riscos') or sys.platform[:4] == 'java': + sitedirs.append(os.path.join(prefix, "Lib", "site-packages")) + elif os.sep == '/': + sitedirs.append(os.path.join(prefix, "lib", + "python" + sys.version[:3], + "site-packages")) + sitedirs.append(os.path.join(prefix, "lib", "site-python")) + else: + sitedirs.append(prefix) + sitedirs.append(os.path.join(prefix, "lib", "site-packages")) + + if sys.platform == "darwin": + # for framework builds *only* we add the standard Apple + # locations. Currently only per-user, but /Library and + # /Network/Library could be added too + if 'Python.framework' in prefix: + sitedirs.append( + os.path.expanduser( + os.path.join("~", "Library", "Python", + sys.version[:3], "site-packages"))) + + for sitedir in sitedirs: + if os.path.isdir(sitedir): + addsitedir(sitedir, known_paths) + + return known_paths + + def setBEGINLIBPATH(): """The OS/2 EMX port has optional extension modules that do double duty as DLLs (and must use the .DLL file extension) for other extensions. @@ -248,12 +322,17 @@ # Shells like IDLE catch the SystemExit, but listen when their # stdin wrapper is closed. try: - sys.stdin.close() + fd = -1 + if hasattr(sys.stdin, "fileno"): + fd = sys.stdin.fileno() + if fd != 0: + # Don't close stdin if it wraps fd 0 + sys.stdin.close() except: pass raise SystemExit(code) - __builtin__.quit = Quitter('quit') - __builtin__.exit = Quitter('exit') + builtins.quit = Quitter('quit') + builtins.exit = Quitter('exit') class _Printer(object): @@ -277,7 +356,7 @@ for filename in self.__files: filename = os.path.join(dir, filename) try: - fp = file(filename, "rU") + fp = open(filename, "rU") data = fp.read() fp.close() break @@ -304,32 +383,32 @@ while 1: try: for i in range(lineno, lineno + self.MAXLINES): - print self.__lines[i] + print(self.__lines[i]) except IndexError: break else: lineno += self.MAXLINES key = None while key is None: - key = raw_input(prompt) + key = input(prompt) if key not in ('', 'q'): key = None if key == 'q': break def setcopyright(): - """Set 'copyright' and 'credits' in __builtin__""" - __builtin__.copyright = _Printer("copyright", sys.copyright) + """Set 'copyright' and 'credits' in builtins""" + builtins.copyright = _Printer("copyright", sys.copyright) if sys.platform[:4] == 'java': - __builtin__.credits = _Printer( + builtins.credits = _Printer( "credits", "Jython is maintained by the Jython developers (www.jython.org).") else: - __builtin__.credits = _Printer("credits", """\ + builtins.credits = _Printer("credits", """\ Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands for supporting Python development. See www.python.org for more information.""") here = os.path.dirname(os.__file__) - __builtin__.license = _Printer( + builtins.license = _Printer( "license", "See http://www.python.org/%.3s/license.html" % sys.version, ["LICENSE.txt", "LICENSE"], [os.path.join(here, os.pardir), here, os.curdir]) @@ -349,7 +428,7 @@ return pydoc.help(*args, **kwds) def sethelper(): - __builtin__.help = _Helper() + builtins.help = _Helper() def aliasmbcs(): """On Windows, some default encodings are not provided by Python, @@ -392,15 +471,35 @@ import sitecustomize except ImportError: pass + except Exception as err: + if os.environ.get("PYTHONVERBOSE"): + raise + sys.stderr.write( + "Error in sitecustomize; set PYTHONVERBOSE for traceback:\n" + "%s: %s\n" % + (err.__class__.__name__, err)) +def execusercustomize(): + """Run custom user specific code, if available.""" + try: + import usercustomize + except ImportError: + pass + + def main(): + global ENABLE_USER_SITE + abs__file__() - paths_in_sys = removeduppaths() + known_paths = removeduppaths() if (os.name == "posix" and sys.path and os.path.basename(sys.path[-1]) == "Modules"): addbuilddir() - paths_in_sys = addsitepackages(paths_in_sys) + if ENABLE_USER_SITE is None: + ENABLE_USER_SITE = check_enableusersite() + known_paths = addusersitepackages(known_paths) + known_paths = addsitepackages(known_paths) if sys.platform == 'os2emx': setBEGINLIBPATH() setquit() @@ -409,6 +508,8 @@ aliasmbcs() setencoding() execsitecustomize() + if ENABLE_USER_SITE: + execusercustomize() # Remove sys.setdefaultencoding() so that users cannot change the # encoding after initialization. The test for presence is needed when # this module is run as a script, because this code is executed twice. @@ -417,11 +518,54 @@ main() -def _test(): - print "sys.path = [" - for dir in sys.path: - print " %r," % (dir,) - print "]" +def _script(): + help = """\ + %s [--user-base] [--user-site] + Without arguments print some useful information + With arguments print the value of USER_BASE and/or USER_SITE separated + by '%s'. + + Exit codes with --user-base or --user-site: + 0 - user site directory is enabled + 1 - user site directory is disabled by user + 2 - uses site directory is disabled by super user + or for security reasons + >2 - unknown error + """ + args = sys.argv[1:] + if not args: + print("sys.path = [") + for dir in sys.path: + print(" %r," % (dir,)) + print("]") + print("USER_BASE: %r (%s)" % (USER_BASE, + "exists" if os.path.isdir(USER_BASE) else "doesn't exist")) + print("USER_SITE: %r (%s)" % (USER_SITE, + "exists" if os.path.isdir(USER_SITE) else "doesn't exist")) + print("ENABLE_USER_SITE: %r" % ENABLE_USER_SITE) + sys.exit(0) + + buffer = [] + if '--user-base' in args: + buffer.append(USER_BASE) + if '--user-site' in args: + buffer.append(USER_SITE) + + if buffer: + print(os.pathsep.join(buffer)) + if ENABLE_USER_SITE: + sys.exit(0) + elif ENABLE_USER_SITE is False: + sys.exit(1) + elif ENABLE_USER_SITE is None: + sys.exit(2) + else: + sys.exit(3) + else: + import textwrap + print(textwrap.dedent(help % (sys.argv[0], os.pathsep))) + sys.exit(10) + if __name__ == '__main__': - _test() + _script() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-05 18:48:59
|
Revision: 5852 http://jython.svn.sourceforge.net/jython/?rev=5852&view=rev Author: fwierzbicki Date: 2009-01-05 18:48:54 +0000 (Mon, 05 Jan 2009) Log Message: ----------- Just enough patchwork to get this thing compiling. Modified Paths: -------------- branches/jy3k/grammar/Python.g branches/jy3k/src/org/python/antlr/GrammarActions.java branches/jy3k/src/org/python/antlr/adapter/AstAdapters.java branches/jy3k/src/org/python/compiler/ArgListCompiler.java branches/jy3k/src/org/python/compiler/CodeCompiler.java branches/jy3k/src/org/python/compiler/ScopesCompiler.java Added Paths: ----------- branches/jy3k/src/org/python/antlr/adapter/ArgAdapter.java Modified: branches/jy3k/grammar/Python.g =================================================================== --- branches/jy3k/grammar/Python.g 2009-01-05 17:59:06 UTC (rev 5851) +++ branches/jy3k/grammar/Python.g 2009-01-05 18:48:54 UTC (rev 5852) @@ -498,7 +498,7 @@ //tfpdef: NAME [':' test] tfpdef[expr_contextType ctype] @after { - actions.checkAssign(actions.castExpr($vfpdef.tree)); + actions.checkAssign(actions.castExpr($tfpdef.tree)); } : NAME (':' test[ctype])? -> ^(NAME<Name>[$NAME, $NAME.text, ctype]) @@ -905,10 +905,10 @@ } ; -//except_clause: 'except' [test [',' test]] +//except_clause: 'except' [test ['as' NAME]] except_clause - : EXCEPT (t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Store])?)? COLON suite[!$suite.isEmpty() && $suite::continueIllegal] - -> ^(EXCEPT<ExceptHandler>[$EXCEPT, actions.castExpr($t1.tree), actions.castExpr($t2.tree), + : EXCEPT (test[expr_contextType.Load] (AS NAME)?)? COLON suite[!$suite.isEmpty() && $suite::continueIllegal] + -> ^(EXCEPT<ExceptHandler>[$EXCEPT, actions.castExpr($test.tree), $NAME.getText(), actions.castStmts($suite.stypes)]) ; @@ -1434,6 +1434,9 @@ } stype = new ClassDef(t, actions.cantBeNone($NAME), actions.makeBases(actions.castExpr($testlist.tree)), + new ArrayList<keyword>(), + null, + null, actions.castStmts($suite.stypes), actions.castExprs($decorators.etypes)); } Modified: branches/jy3k/src/org/python/antlr/GrammarActions.java =================================================================== --- branches/jy3k/src/org/python/antlr/GrammarActions.java 2009-01-05 17:59:06 UTC (rev 5851) +++ branches/jy3k/src/org/python/antlr/GrammarActions.java 2009-01-05 18:48:54 UTC (rev 5852) @@ -155,8 +155,7 @@ List<arg> castArgs(List args) { List<arg> result = new ArrayList<arg>(); if (args != null) { - for (int i=start; i<args.size(); i++) { - Object o = args.get(i); + for (Object o : args) { if (o instanceof arg) { result.add((arg)o); } @@ -268,7 +267,7 @@ } List<stmt> s = castStmts(funcStatements); List<expr> d = castExprs(decorators); - return new FunctionDef(t, nameToken.getText(), a, s, d); + return new FunctionDef(t, nameToken.getText(), a, s, d, null); } List<expr> makeAssignTargets(expr lhs, List rhs) { @@ -496,8 +495,8 @@ cantBeNone(nameToken); List<expr> b = castExprs(bases); List<stmt> s = castStmts(body); - List<expr> d = castExprs(decorators); - return new ClassDef(t, nameToken.getText(), b, s, d); + List<expr> d = castExprs(decorators); + return new ClassDef(t, nameToken.getText(), b, new ArrayList<keyword>(), null, null, s, d); } stmt makeTryExcept(PythonTree t, List body, List handlers, List orelse, List finBody) { Added: branches/jy3k/src/org/python/antlr/adapter/ArgAdapter.java =================================================================== --- branches/jy3k/src/org/python/antlr/adapter/ArgAdapter.java (rev 0) +++ branches/jy3k/src/org/python/antlr/adapter/ArgAdapter.java 2009-01-05 18:48:54 UTC (rev 5852) @@ -0,0 +1,35 @@ +package org.python.antlr.adapter; + +import java.util.ArrayList; +import java.util.List; + +import org.python.antlr.ast.arg; +import org.python.core.Py; +import org.python.core.PyObject; + +public class ArgAdapter implements AstAdapter { + + public Object py2ast(PyObject o) { + if (o == null || o instanceof arg) { + return o; + } else if (o == Py.None) { + return null; + } + + //FIXME: investigate the right exception + throw Py.TypeError("Can't convert " + o.getClass().getName() + " to arg node"); + } + + public PyObject ast2py(Object o) { + return (PyObject)o; + } + + public List iter2ast(PyObject iter) { + List<arg> args = new ArrayList<arg>(); + for(Object o : (Iterable)iter) { + args.add((arg)py2ast((PyObject)o)); + } + return args; + } + +} Modified: branches/jy3k/src/org/python/antlr/adapter/AstAdapters.java =================================================================== --- branches/jy3k/src/org/python/antlr/adapter/AstAdapters.java 2009-01-05 17:59:06 UTC (rev 5851) +++ branches/jy3k/src/org/python/antlr/adapter/AstAdapters.java 2009-01-05 18:48:54 UTC (rev 5852) @@ -11,6 +11,7 @@ */ public class AstAdapters { public static AliasAdapter aliasAdapter = new AliasAdapter(); + public static ArgAdapter argAdapter = new ArgAdapter(); public static CmpopAdapter cmpopAdapter = new CmpopAdapter(); public static ComprehensionAdapter comprehensionAdapter = new ComprehensionAdapter(); public static ExcepthandlerAdapter excepthandlerAdapter = new ExcepthandlerAdapter(); @@ -24,6 +25,10 @@ return (java.util.List<alias>)aliasAdapter.iter2ast(o); } + public static java.util.List<arg> py2argList(PyObject o) { + return (java.util.List<arg>)argAdapter.iter2ast(o); + } + public static java.util.List<cmpopType> py2cmpopList(PyObject o) { return (java.util.List<cmpopType>)cmpopAdapter.iter2ast(o); } Modified: branches/jy3k/src/org/python/compiler/ArgListCompiler.java =================================================================== --- branches/jy3k/src/org/python/compiler/ArgListCompiler.java 2009-01-05 17:59:06 UTC (rev 5851) +++ branches/jy3k/src/org/python/compiler/ArgListCompiler.java 2009-01-05 18:48:54 UTC (rev 5852) @@ -51,14 +51,6 @@ for (int i = 0; i < args.getInternalArgs().size(); i++) { String name = (String) visit(args.getInternalArgs().get(i)); names.add(name); - if (args.getInternalArgs().get(i) instanceof Tuple) { - List<expr> targets = new ArrayList<expr>(); - targets.add(args.getInternalArgs().get(i)); - Assign ass = new Assign(args.getInternalArgs().get(i), - targets, - new Name(args.getInternalArgs().get(i), name, expr_contextType.Load)); - init_code.add(ass); - } } if (args.getInternalVararg() != null) { arglist = true; Modified: branches/jy3k/src/org/python/compiler/CodeCompiler.java =================================================================== --- branches/jy3k/src/org/python/compiler/CodeCompiler.java 2009-01-05 17:59:06 UTC (rev 5851) +++ branches/jy3k/src/org/python/compiler/CodeCompiler.java 2009-01-05 18:48:54 UTC (rev 5852) @@ -1057,7 +1057,12 @@ if (handler.getInternalName() != null) { code.aload(exc); code.getfield("org/python/core/PyException", "value", "Lorg/python/core/PyObject;"); - set(handler.getInternalName()); + + //XXX: in 3.0 name is now a string, not a node. + //set(handler.getInternalName()); + String name = getName(handler.getInternalName()); + code.ldc(name); + } //do exception body Modified: branches/jy3k/src/org/python/compiler/ScopesCompiler.java =================================================================== --- branches/jy3k/src/org/python/compiler/ScopesCompiler.java 2009-01-05 17:59:06 UTC (rev 5851) +++ branches/jy3k/src/org/python/compiler/ScopesCompiler.java 2009-01-05 18:48:54 UTC (rev 5852) @@ -4,6 +4,7 @@ import org.python.antlr.Visitor; import org.python.antlr.PythonTree; +import org.python.antlr.ast.arg; import org.python.antlr.ast.ClassDef; import org.python.antlr.ast.Expression; import org.python.antlr.ast.FunctionDef; @@ -301,9 +302,9 @@ + ")"; def(tmp); ArgListCompiler ac = new ArgListCompiler(); - List<expr> args = new ArrayList<expr>(); - args.add(new Name(node.getToken(), bound_exp, expr_contextType.Param)); - ac.visitArgs(new arguments(node, args, null, null, new ArrayList<expr>())); + List<arg> args = new ArrayList<arg>(); + args.add(new arg(node, bound_exp, null)); + ac.visitArgs(new arguments(node, args, null, null, new ArrayList<arg>(), null, null, new ArrayList<expr>(), new ArrayList<expr>())); beginScope(tmp, FUNCSCOPE, node, ac); cur.addParam(bound_exp); cur.markFromParam(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-05 17:59:09
|
Revision: 5851 http://jython.svn.sourceforge.net/jython/?rev=5851&view=rev Author: fwierzbicki Date: 2009-01-05 17:59:06 +0000 (Mon, 05 Jan 2009) Log Message: ----------- Just enough to get ast.arguments constructor calls passing. Modified Paths: -------------- branches/jy3k/grammar/Python.g branches/jy3k/src/org/python/antlr/GrammarActions.java Modified: branches/jy3k/grammar/Python.g =================================================================== --- branches/jy3k/grammar/Python.g 2009-01-05 13:51:12 UTC (rev 5850) +++ branches/jy3k/grammar/Python.g 2009-01-05 17:59:06 UTC (rev 5851) @@ -84,6 +84,7 @@ import org.python.antlr.ParseException; import org.python.antlr.PythonTree; import org.python.antlr.ast.alias; +import org.python.antlr.ast.arg; import org.python.antlr.ast.arguments; import org.python.antlr.ast.Assert; import org.python.antlr.ast.Assign; @@ -447,7 +448,7 @@ parameters returns [arguments args] : LPAREN (varargslist {$args = $varargslist.args;} - | { $args = new arguments($parameters.start, new ArrayList<expr>(), null, null, new ArrayList<expr>()); + | { $args = new arguments($parameters.start, new ArrayList<arg>(), null, null, new ArrayList<arg>(), null, null, new ArrayList<expr>(), new ArrayList<expr>()); } ) RPAREN @@ -486,7 +487,7 @@ } | STAR starargs=tfpdef[expr_contextType.Param] (COMMA DOUBLESTAR kwargs=tfpdef[expr_contextType.Param])? { - $args = actions.makeArgumentsType($typedargslist.start, $d, $starargs.tree.tree, $kwargs.tree, defaults); + $args = actions.makeArgumentsType($typedargslist.start, $d, $starargs.tree, $kwargs.tree, defaults); } | DOUBLESTAR kwargs=tfpdef[expr_contextType.Param] { @@ -1310,7 +1311,7 @@ { arguments a = $varargslist.args; if (a == null) { - a = new arguments($LAMBDA, new ArrayList<expr>(), null, null, new ArrayList<expr>()); + a = new arguments($LAMBDA, new ArrayList<arg>(), null, null, new ArrayList<arg>(), null, null, new ArrayList<expr>(), new ArrayList<expr>()); } etype = new Lambda($LAMBDA, a, actions.castExpr($test.tree)); } Modified: branches/jy3k/src/org/python/antlr/GrammarActions.java =================================================================== --- branches/jy3k/src/org/python/antlr/GrammarActions.java 2009-01-05 13:51:12 UTC (rev 5850) +++ branches/jy3k/src/org/python/antlr/GrammarActions.java 2009-01-05 17:59:06 UTC (rev 5851) @@ -10,6 +10,7 @@ import org.python.core.PyString; import org.python.core.PyUnicode; import org.python.antlr.ast.alias; +import org.python.antlr.ast.arg; import org.python.antlr.ast.arguments; import org.python.antlr.ast.boolopType; import org.python.antlr.ast.cmpopType; @@ -150,7 +151,20 @@ } return result; } - + + List<arg> castArgs(List args) { + List<arg> result = new ArrayList<arg>(); + if (args != null) { + for (int i=start; i<args.size(); i++) { + Object o = args.get(i); + if (o instanceof arg) { + result.add((arg)o); + } + } + } + return result; + } + List<stmt> makeElse(List elseSuite, PythonTree elif) { if (elseSuite != null) { return castStmts(elseSuite); @@ -250,7 +264,7 @@ if (args != null) { a = args; } else { - a = new arguments(t, new ArrayList<expr>(), null, null, new ArrayList<expr>()); + a = new arguments(t, new ArrayList<arg>(), null, null, new ArrayList<arg>(), null, null, new ArrayList<expr>(), new ArrayList<expr>()); } List<stmt> s = castStmts(funcStatements); List<expr> d = castExprs(decorators); @@ -292,10 +306,10 @@ } } - arguments makeArgumentsType(Token t, List params, Token snameToken, - Token knameToken, List defaults) { + arguments makeArgumentsType(Token t, List params, PythonTree snameToken, + PythonTree knameToken, List defaults) { - List<expr> p = castExprs(params); + List<arg> p = castArgs(params); List<expr> d = castExprs(defaults); String s; String k; @@ -309,7 +323,7 @@ } else { k = cantBeNone(knameToken); } - return new arguments(t, p, s, k, d); + return new arguments(t, p, s, null, new ArrayList<arg>(), k, null, d, new ArrayList<expr>()); } List<expr> extractArgs(List args) { @@ -591,10 +605,11 @@ return t.getText(); } - void cantBeNone(PythonTree e) { + String cantBeNone(PythonTree e) { if (e.getText().equals("None")) { errorHandler.error("can't be None", e); } + return e.getText(); } void checkAssign(expr e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-05 13:51:17
|
Revision: 5850 http://jython.svn.sourceforge.net/jython/?rev=5850&view=rev Author: fwierzbicki Date: 2009-01-05 13:51:12 +0000 (Mon, 05 Jan 2009) Log Message: ----------- Raise now takes only 2 args. Modified Paths: -------------- branches/jy3k/grammar/Python.g branches/jy3k/src/org/python/compiler/CodeCompiler.java Modified: branches/jy3k/grammar/Python.g =================================================================== --- branches/jy3k/grammar/Python.g 2009-01-05 13:39:31 UTC (rev 5849) +++ branches/jy3k/grammar/Python.g 2009-01-05 13:51:12 UTC (rev 5850) @@ -699,11 +699,10 @@ : yield_expr -> ^(YIELD<Expr>[$yield_expr.start, actions.castExpr($yield_expr.tree)]) ; -//raise_stmt: 'raise' [test [',' test [',' test]]] +//raise_stmt: 'raise' [test ['from' test]] raise_stmt - : RAISE (t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load] - (COMMA t3=test[expr_contextType.Load])?)?)? - -> ^(RAISE<Raise>[$RAISE, actions.castExpr($t1.tree), actions.castExpr($t2.tree), actions.castExpr($t3.tree)]) + : RAISE (t1=test[expr_contextType.Load] (FROM t2=test[expr_contextType.Load])?)? + -> ^(RAISE<Raise>[$RAISE, actions.castExpr($t1.tree), actions.castExpr($t2.tree)]) ; //import_stmt: import_name | import_from Modified: branches/jy3k/src/org/python/compiler/CodeCompiler.java =================================================================== --- branches/jy3k/src/org/python/compiler/CodeCompiler.java 2009-01-05 13:39:31 UTC (rev 5849) +++ branches/jy3k/src/org/python/compiler/CodeCompiler.java 2009-01-05 13:51:12 UTC (rev 5850) @@ -705,20 +705,16 @@ @Override public Object visitRaise(Raise node) throws Exception { setline(node); - if (node.getInternalExcepttype() != null) { visit(node.getInternalExcepttype()); stackProduce(); } - if (node.getInternalInst() != null) { visit(node.getInternalInst()); stackProduce(); } - if (node.getInternalTback() != null) { visit(node.getInternalTback()); stackProduce(); } - if (node.getInternalExcepttype() == null) { + if (node.getInternalExc() != null) { visit(node.getInternalExc()); stackProduce(); } + if (node.getInternalCause() != null) { visit(node.getInternalCause()); stackProduce(); } + if (node.getInternalExc() == null) { code.invokestatic("org/python/core/Py", "makeException", "()" + $pyExc); - } else if (node.getInternalInst() == null) { + } else if (node.getInternalCause() == null) { stackConsume(); code.invokestatic("org/python/core/Py", "makeException", "(" + $pyObj + ")" + $pyExc); - } else if (node.getInternalTback() == null) { + } else { stackConsume(2); code.invokestatic("org/python/core/Py", "makeException", "(" + $pyObj + $pyObj + ")" + $pyExc); - } else { - stackConsume(3); - code.invokestatic("org/python/core/Py", "makeException", "(" + $pyObj + $pyObj + $pyObj + ")" + $pyExc); } code.athrow(); return Exit; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-05 13:39:43
|
Revision: 5849 http://jython.svn.sourceforge.net/jython/?rev=5849&view=rev Author: fwierzbicki Date: 2009-01-05 13:39:31 +0000 (Mon, 05 Jan 2009) Log Message: ----------- print, exec, repr no longer exist. Modified Paths: -------------- branches/jy3k/grammar/Python.g branches/jy3k/src/org/python/antlr/GrammarActions.java branches/jy3k/src/org/python/antlr/ast/AstModule.java branches/jy3k/src/org/python/compiler/CodeCompiler.java branches/jy3k/src/org/python/compiler/ScopesCompiler.java Removed Paths: ------------- branches/jy3k/src/org/python/antlr/ast/ExecDerived.java branches/jy3k/src/org/python/antlr/ast/PrintDerived.java branches/jy3k/src/org/python/antlr/ast/ReprDerived.java Modified: branches/jy3k/grammar/Python.g =================================================================== --- branches/jy3k/grammar/Python.g 2009-01-05 13:16:44 UTC (rev 5848) +++ branches/jy3k/grammar/Python.g 2009-01-05 13:39:31 UTC (rev 5849) @@ -127,7 +127,6 @@ import org.python.antlr.ast.operatorType; import org.python.antlr.ast.Pass; import org.python.antlr.ast.Raise; -import org.python.antlr.ast.Repr; import org.python.antlr.ast.Return; import org.python.antlr.ast.Slice; import org.python.antlr.ast.Str; @@ -455,69 +454,107 @@ ; //not in CPython's Grammar file -defparameter[List defaults] returns [expr etype] +tdefparameter[List defaults] returns [expr etype] @after { - $defparameter.tree = $etype; + $tdefparameter.tree = $etype; } - : fpdef[expr_contextType.Param] (ASSIGN test[expr_contextType.Load])? + : vfpdef[expr_contextType.Param] (ASSIGN test[expr_contextType.Load])? { - $etype = actions.castExpr($fpdef.tree); + $etype = actions.castExpr($vfpdef.tree); if ($ASSIGN != null) { defaults.add($test.tree); } else if (!defaults.isEmpty()) { - throw new ParseException("non-default argument follows default argument", $fpdef.tree); + throw new ParseException("non-default argument follows default argument", $vfpdef.tree); } } ; - -//varargslist: ((fpdef ['=' test] ',')* -// ('*' NAME [',' '**' NAME] | '**' NAME) | -// fpdef ['=' test] (',' fpdef ['=' test])* [',']) -varargslist returns [arguments args] +//typedargslist: ((tfpdef ['=' test] ',')* +// ('*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef) +// | tfpdef ['=' test] (',' tfpdef ['=' test])* [',']) +typedargslist returns [arguments args] @init { List defaults = new ArrayList(); } - : d+=defparameter[defaults] (options {greedy=true;}:COMMA d+=defparameter[defaults])* + : d+=tdefparameter[defaults] (options {greedy=true;}:COMMA d+=tdefparameter[defaults])* (COMMA - (STAR starargs=NAME (COMMA DOUBLESTAR kwargs=NAME)? - | DOUBLESTAR kwargs=NAME + (STAR (starargs=tfpdef[expr_contextType.Param])? (COMMA tdefparameter[defaults])* (COMMA DOUBLESTAR kwargs=tfpdef[expr_contextType.Param])? + | DOUBLESTAR kwargs=tfpdef[expr_contextType.Param] )? )? { - $args = actions.makeArgumentsType($varargslist.start, $d, $starargs, $kwargs, defaults); + $args = actions.makeArgumentsType($typedargslist.start, $d, $starargs.tree, $kwargs.tree, defaults); } - | STAR starargs=NAME (COMMA DOUBLESTAR kwargs=NAME)? + | STAR starargs=tfpdef[expr_contextType.Param] (COMMA DOUBLESTAR kwargs=tfpdef[expr_contextType.Param])? { - $args = actions.makeArgumentsType($varargslist.start, $d, $starargs, $kwargs, defaults); + $args = actions.makeArgumentsType($typedargslist.start, $d, $starargs.tree.tree, $kwargs.tree, defaults); } - | DOUBLESTAR kwargs=NAME + | DOUBLESTAR kwargs=tfpdef[expr_contextType.Param] { - $args = actions.makeArgumentsType($varargslist.start, $d, null, $kwargs, defaults); + $args = actions.makeArgumentsType($typedargslist.start, $d, null, $kwargs.tree, defaults); } ; -//fpdef: NAME | '(' fplist ')' -fpdef[expr_contextType ctype] +//tfpdef: NAME [':' test] +tfpdef[expr_contextType ctype] @after { - actions.checkAssign(actions.castExpr($fpdef.tree)); + actions.checkAssign(actions.castExpr($vfpdef.tree)); } - : NAME + : NAME (':' test[ctype])? -> ^(NAME<Name>[$NAME, $NAME.text, ctype]) - | (LPAREN fpdef[null] COMMA) => LPAREN fplist RPAREN - -> ^(LPAREN<Tuple>[$fplist.start, actions.castExprs($fplist.etypes), expr_contextType.Store]) - | LPAREN fplist RPAREN - -> fplist ; -//fplist: fpdef (',' fpdef)* [','] -fplist returns [List etypes] - : f+=fpdef[expr_contextType.Store] - (options {greedy=true;}:COMMA f+=fpdef[expr_contextType.Store])* (COMMA)? +//not in CPython's Grammar file +vdefparameter[List defaults] returns [expr etype] +@after { + $vdefparameter.tree = $etype; +} + : vfpdef[expr_contextType.Param] (ASSIGN test[expr_contextType.Load])? { - $etypes = $f; + $etype = actions.castExpr($vfpdef.tree); + if ($ASSIGN != null) { + defaults.add($test.tree); + } else if (!defaults.isEmpty()) { + throw new ParseException("non-default argument follows default argument", $vfpdef.tree); + } } ; +//varargslist: ((vfpdef ['=' test] ',')* +// ('*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef) +// vfpdef ['=' test] (',' vfpdef ['=' test])* [',']) +varargslist returns [arguments args] +@init { + List defaults = new ArrayList(); +} + : d+=vdefparameter[defaults] (options {greedy=true;}:COMMA d+=vdefparameter[defaults])* + (COMMA + (STAR (starargs=vfpdef[expr_contextType.Param])? (COMMA DOUBLESTAR kwargs=vfpdef[expr_contextType.Param])? + | DOUBLESTAR kwargs=vfpdef[expr_contextType.Param] + )? + )? + { + $args = actions.makeArgumentsType($varargslist.start, $d, $starargs.tree, $kwargs.tree, defaults); + } + | STAR starargs=vfpdef[expr_contextType.Param] (COMMA DOUBLESTAR kwargs=vfpdef[expr_contextType.Param])? + { + $args = actions.makeArgumentsType($varargslist.start, $d, $starargs.tree, $kwargs.tree, defaults); + } + | DOUBLESTAR kwargs=vfpdef[expr_contextType.Param] + { + $args = actions.makeArgumentsType($varargslist.start, $d, null, $kwargs.tree, defaults); + } + ; + +//vfpdef: NAME +vfpdef[expr_contextType ctype] +@after { + actions.checkAssign(actions.castExpr($vfpdef.tree)); +} + : NAME + -> ^(NAME<Name>[$NAME, $NAME.text, ctype]) + ; + + //stmt: simple_stmt | compound_stmt stmt returns [List stypes] : simple_stmt @@ -1194,8 +1231,6 @@ -> ^(LCURLY<Dict>[$LCURLY, new ArrayList<expr>(), new ArrayList<expr>()]) ) RCURLY - | lb=BACKQUOTE testlist[expr_contextType.Load] rb=BACKQUOTE - -> ^(BACKQUOTE<Repr>[$lb, actions.castExpr($testlist.tree)]) | NAME -> ^(NAME<Name>[$NAME, $NAME.text, $expr::ctype]) | INT Modified: branches/jy3k/src/org/python/antlr/GrammarActions.java =================================================================== --- branches/jy3k/src/org/python/antlr/GrammarActions.java 2009-01-05 13:16:44 UTC (rev 5848) +++ branches/jy3k/src/org/python/antlr/GrammarActions.java 2009-01-05 13:39:31 UTC (rev 5849) @@ -41,7 +41,6 @@ import org.python.antlr.ast.TryExcept; import org.python.antlr.ast.TryFinally; import org.python.antlr.ast.Tuple; -import org.python.antlr.ast.Repr; import org.python.antlr.ast.Str; import org.python.antlr.ast.UnaryOp; import org.python.antlr.ast.While; @@ -615,8 +614,6 @@ errorHandler.error("can't assign to lambda", e); } else if (e instanceof Call) { errorHandler.error("can't assign to function call", e); - } else if (e instanceof Repr) { - errorHandler.error("can't assign to repr", e); } else if (e instanceof IfExp) { errorHandler.error("can't assign to conditional expression", e); } else if (e instanceof ListComp) { Modified: branches/jy3k/src/org/python/antlr/ast/AstModule.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/AstModule.java 2009-01-05 13:16:44 UTC (rev 5848) +++ branches/jy3k/src/org/python/antlr/ast/AstModule.java 2009-01-05 13:39:31 UTC (rev 5849) @@ -52,7 +52,6 @@ // dict.__setitem__("ErrorSlice", ErrorSlice.TYPE); // dict.__setitem__("ErrorStmt", ErrorStmt.TYPE); dict.__setitem__("ExceptHandler", ExceptHandler.TYPE); - dict.__setitem__("Exec", Exec.TYPE); dict.__setitem__("Expr", Expr.TYPE); dict.__setitem__("Expression", Expression.TYPE); dict.__setitem__("ExtSlice", ExtSlice.TYPE); @@ -73,9 +72,7 @@ dict.__setitem__("Name", Name.TYPE); dict.__setitem__("Num", Num.TYPE); dict.__setitem__("Pass", Pass.TYPE); - dict.__setitem__("Print", Print.TYPE); dict.__setitem__("Raise", Raise.TYPE); - dict.__setitem__("Repr", Repr.TYPE); dict.__setitem__("Return", Return.TYPE); dict.__setitem__("Slice", Slice.TYPE); dict.__setitem__("Str", Str.TYPE); Deleted: branches/jy3k/src/org/python/antlr/ast/ExecDerived.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/ExecDerived.java 2009-01-05 13:16:44 UTC (rev 5848) +++ branches/jy3k/src/org/python/antlr/ast/ExecDerived.java 2009-01-05 13:39:31 UTC (rev 5849) @@ -1,1163 +0,0 @@ -/* Generated file, do not modify. See jython/src/templates/gderived.py. */ -package org.python.antlr.ast; - -import java.io.Serializable; -import org.python.core.*; - -public class ExecDerived extends Exec implements Slotted { - - public PyObject getSlot(int index) { - return slots[index]; - } - - public void setSlot(int index,PyObject value) { - slots[index]=value; - } - - private PyObject[]slots; - - private PyObject dict; - - public PyObject fastGetDict() { - return dict; - } - - public PyObject getDict() { - return dict; - } - - public void setDict(PyObject newDict) { - if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) { - dict=newDict; - } else { - throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName()); - } - } - - public void delDict() { - // deleting an object's instance dict makes it grow a new one - dict=new PyStringMap(); - } - - public ExecDerived(PyType subtype) { - super(subtype); - slots=new PyObject[subtype.getNumSlots()]; - dict=subtype.instDict(); - } - - public PyString __str__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__str__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyString) - return(PyString)res; - throw Py.TypeError("__str__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); - } - return super.__str__(); - } - - public PyString __repr__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__repr__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyString) - return(PyString)res; - throw Py.TypeError("__repr__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); - } - return super.__repr__(); - } - - public PyString __hex__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__hex__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyString) - return(PyString)res; - throw Py.TypeError("__hex__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); - } - return super.__hex__(); - } - - public PyString __oct__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__oct__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyString) - return(PyString)res; - throw Py.TypeError("__oct__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); - } - return super.__oct__(); - } - - public PyFloat __float__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__float__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyFloat) - return(PyFloat)res; - throw Py.TypeError("__float__"+" returned non-"+"float"+" (type "+res.getType().fastGetName()+")"); - } - return super.__float__(); - } - - public PyComplex __complex__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__complex__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyComplex) - return(PyComplex)res; - throw Py.TypeError("__complex__"+" returned non-"+"complex"+" (type "+res.getType().fastGetName()+")"); - } - return super.__complex__(); - } - - public PyObject __pos__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__pos__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__pos__(); - } - - public PyObject __neg__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__neg__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__neg__(); - } - - public PyObject __abs__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__abs__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__abs__(); - } - - public PyObject __invert__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__invert__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__invert__(); - } - - public PyObject __reduce__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__reduce__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__reduce__(); - } - - public PyObject __add__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__add__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__add__(other); - } - - public PyObject __radd__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__radd__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__radd__(other); - } - - public PyObject __sub__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__sub__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__sub__(other); - } - - public PyObject __rsub__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rsub__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rsub__(other); - } - - public PyObject __mul__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__mul__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__mul__(other); - } - - public PyObject __rmul__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rmul__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rmul__(other); - } - - public PyObject __div__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__div__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__div__(other); - } - - public PyObject __rdiv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rdiv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rdiv__(other); - } - - public PyObject __floordiv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__floordiv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__floordiv__(other); - } - - public PyObject __rfloordiv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rfloordiv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rfloordiv__(other); - } - - public PyObject __truediv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__truediv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__truediv__(other); - } - - public PyObject __rtruediv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rtruediv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rtruediv__(other); - } - - public PyObject __mod__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__mod__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__mod__(other); - } - - public PyObject __rmod__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rmod__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rmod__(other); - } - - public PyObject __divmod__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__divmod__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__divmod__(other); - } - - public PyObject __rdivmod__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rdivmod__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rdivmod__(other); - } - - public PyObject __rpow__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rpow__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rpow__(other); - } - - public PyObject __lshift__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__lshift__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__lshift__(other); - } - - public PyObject __rlshift__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rlshift__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rlshift__(other); - } - - public PyObject __rshift__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rshift__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rshift__(other); - } - - public PyObject __rrshift__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rrshift__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rrshift__(other); - } - - public PyObject __and__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__and__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__and__(other); - } - - public PyObject __rand__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rand__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rand__(other); - } - - public PyObject __or__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__or__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__or__(other); - } - - public PyObject __ror__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__ror__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__ror__(other); - } - - public PyObject __xor__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__xor__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__xor__(other); - } - - public PyObject __rxor__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rxor__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rxor__(other); - } - - public PyObject __lt__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__lt__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__lt__(other); - } - - public PyObject __le__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__le__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__le__(other); - } - - public PyObject __gt__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__gt__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__gt__(other); - } - - public PyObject __ge__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__ge__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__ge__(other); - } - - public PyObject __eq__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__eq__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__eq__(other); - } - - public PyObject __ne__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__ne__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__ne__(other); - } - - public PyObject __iadd__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__iadd__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__iadd__(other); - } - - public PyObject __isub__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__isub__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__isub__(other); - } - - public PyObject __imul__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__imul__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__imul__(other); - } - - public PyObject __idiv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__idiv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__idiv__(other); - } - - public PyObject __ifloordiv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__ifloordiv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__ifloordiv__(other); - } - - public PyObject __itruediv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__itruediv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__itruediv__(other); - } - - public PyObject __imod__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__imod__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__imod__(other); - } - - public PyObject __ipow__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__ipow__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__ipow__(other); - } - - public PyObject __ilshift__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__ilshift__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__ilshift__(other); - } - - public PyObject __irshift__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__irshift__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__irshift__(other); - } - - public PyObject __iand__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__iand__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__iand__(other); - } - - public PyObject __ior__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__ior__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__ior__(other); - } - - public PyObject __ixor__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__ixor__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__ixor__(other); - } - - public PyObject __int__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__int__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyInteger||res instanceof PyLong) - return(PyObject)res; - throw Py.TypeError("__int__"+" should return an integer"); - } - 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__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyInteger) { - return((PyInteger)res).getValue(); - } else - if (res instanceof PyLong) { - return((PyLong)res).getValue().intValue(); - } - throw Py.TypeError("__hash__ should return a int"); - } - if (self_type.lookup("__eq__")!=null||self_type.lookup("__cmp__")!=null) { - throw Py.TypeError(String.format("unhashable type: '%.200s'",getType().fastGetName())); - } - return super.hashCode(); - } - - public PyUnicode __unicode__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__unicode__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyUnicode) - return(PyUnicode)res; - if (res instanceof PyString) - return new PyUnicode((PyString)res); - throw Py.TypeError("__unicode__"+" should return a "+"unicode"); - } - return super.__unicode__(); - } - - public int __cmp__(PyObject other) { - PyType self_type=getType(); - PyType[]where_type=new PyType[1]; - PyObject impl=self_type.lookup_where("__cmp__",where_type); - // Full Compatibility with CPython __cmp__: - // If the derived type don't override __cmp__, the - // *internal* super().__cmp__ should be called, not the - // exposed one. The difference is that the exposed __cmp__ - // throws a TypeError if the argument is an instance of the same type. - if (impl==null||where_type[0]==TYPE||Py.isSubClass(TYPE,where_type[0])) { - return super.__cmp__(other); - } - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) { - return-2; - } - int c=res.asInt(); - return c<0?-1:c>0?1:0; - } - - public boolean __nonzero__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__nonzero__"); - if (impl==null) { - impl=self_type.lookup("__len__"); - if (impl==null) - return super.__nonzero__(); - } - PyObject o=impl.__get__(this,self_type).__call__(); - Class c=o.getClass(); - if (c!=PyInteger.class&&c!=PyBoolean.class) { - throw Py.TypeError(String.format("__nonzero__ should return bool or int, returned %s",self_type.getName())); - } - return o.__nonzero__(); - } - - public boolean __contains__(PyObject o) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__contains__"); - if (impl==null) - return super.__contains__(o); - return impl.__get__(this,self_type).__call__(o).__nonzero__(); - } - - public int __len__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__len__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyInteger) - return((PyInteger)res).getValue(); - throw Py.TypeError("__len__ should return a int"); - } - return super.__len__(); - } - - public PyObject __iter__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__iter__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - impl=self_type.lookup("__getitem__"); - if (impl==null) - return super.__iter__(); - return new PySequenceIter(this); - } - - public PyObject __iternext__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("next"); - if (impl!=null) { - try { - return impl.__get__(this,self_type).__call__(); - } catch (PyException exc) { - if (Py.matchException(exc,Py.StopIteration)) - return null; - throw exc; - } - } - return super.__iternext__(); // ??? - } - - public PyObject __finditem__(PyObject key) { // ??? - PyType self_type=getType(); - PyObject impl=self_type.lookup("__getitem__"); - if (impl!=null) - try { - return impl.__get__(this,self_type).__call__(key); - } catch (PyException exc) { - if (Py.matchException(exc,Py.LookupError)) - return null; - throw exc; - } - return super.__finditem__(key); - } - - public PyObject __finditem__(int key) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__getitem__"); - if (impl!=null) - try { - return impl.__get__(this,self_type).__call__(new PyInteger(key)); - } catch (PyException exc) { - if (Py.matchException(exc,Py.LookupError)) - return null; - throw exc; - } - return super.__finditem__(key); - } - - public PyObject __getitem__(PyObject key) { - // Same as __finditem__, without swallowing LookupErrors. This allows - // __getitem__ implementations written in Python to raise custom - // exceptions (such as subclasses of KeyError). - // - // We are forced to duplicate the code, instead of defining __finditem__ - // in terms of __getitem__. That's because PyObject defines __getitem__ - // in terms of __finditem__. Therefore, we would end with an infinite - // loop when self_type.lookup("__getitem__") returns null: - // - // __getitem__ -> super.__getitem__ -> __finditem__ -> __getitem__ - // - // By duplicating the (short) lookup and call code, we are safe, because - // the call chains will be: - // - // __finditem__ -> super.__finditem__ - // - // __getitem__ -> super.__getitem__ -> __finditem__ -> super.__finditem__ - - PyType self_type=getType(); - PyObject impl=self_type.lookup("__getitem__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(key); - return super.__getitem__(key); - } - - public void __setitem__(PyObject key,PyObject value) { // ??? - PyType self_type=getType(); - PyObject impl=self_type.lookup("__setitem__"); - if (impl!=null) { - impl.__get__(this,self_type).__call__(key,value); - return; - } - super.__setitem__(key,value); - } - - public PyObject __getslice__(PyObject start,PyObject stop,PyObject step) { // ??? - if (step!=null) { - return __getitem__(new PySlice(start,stop,step)); - } - PyType self_type=getType(); - PyObject impl=self_type.lookup("__getslice__"); - if (impl!=null) { - PyObject[]indices=PySlice.indices2(this,start,stop); - return impl.__get__(this,self_type).__call__(indices[0],indices[1]); - } - return super.__getslice__(start,stop,step); - } - - public void __setslice__(PyObject start,PyObject stop,PyObject step,PyObject value) { - if (step!=null) { - __setitem__(new PySlice(start,stop,step),value); - return; - } - PyType self_type=getType(); - PyObject impl=self_type.lookup("__setslice__"); - if (impl!=null) { - PyObject[]indices=PySlice.indices2(this,start,stop); - impl.__get__(this,self_type).__call__(indices[0],indices[1],value); - return; - } - super.__setslice__(start,stop,step,value); - } - - public void __delslice__(PyObject start,PyObject stop,PyObject step) { - if (step!=null) { - __delitem__(new PySlice(start,stop,step)); - return; - } - PyType self_type=getType(); - PyObject impl=self_type.lookup("__delslice__"); - if (impl!=null) { - PyObject[]indices=PySlice.indices2(this,start,stop); - impl.__get__(this,self_type).__call__(indices[0],indices[1]); - return; - } - super.__delslice__(start,stop,step); - } - - public void __delitem__(PyObject key) { // ??? - PyType self_type=getType(); - PyObject impl=self_type.lookup("__delitem__"); - if (impl!=null) { - impl.__get__(this,self_type).__call__(key); - return; - } - super.__delitem__(key); - } - - public PyObject __call__(PyObject args[],String keywords[]) { - ThreadState ts=Py.getThreadState(); - if (ts.recursion_depth++>ts.systemState.getrecursionlimit()) - throw Py.RuntimeError("maximum __call__ recursion depth exceeded"); - try { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__call__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(args,keywords); - return super.__call__(args,keywords); - } finally { - --ts.recursion_depth; - } - } - - public PyObject __findattr_ex__(String name) { - PyType self_type=getType(); - // TODO: We should speed this up. As the __getattribute__ slot almost never - // changes, it is a good candidate for caching, as PyClass does with - // __getattr__. See #1102. - PyObject getattribute=self_type.lookup("__getattribute__"); - PyString py_name=null; - PyException firstAttributeError=null; - try { - if (getattribute!=null) { - py_name=PyString.fromInterned(name); - return getattribute.__get__(this,self_type).__call__(py_name); - } else { - Py.Warning(String.format("__getattribute__ not found on type %s",self_type.getName())); - PyObject ret=super.__findattr_ex__(name); - if (ret!=null) { - return ret; - } // else: pass through to __getitem__ invocation - } - } catch (PyException e) { - if (!Py.matchException(e,Py.AttributeError)) { - throw e; - } else { - firstAttributeError=e; // saved to avoid swallowing custom AttributeErrors - // and pass through to __getattr__ invocation. - } - } - PyObject getattr=self_type.lookup("__getattr__"); - if (getattr!=null) { - if (py_name==null) { - py_name=PyString.fromInterned(name); - } - return getattr.__get__(this,self_type).__call__(py_name); - } - if (firstAttributeError!=null) { - throw firstAttributeError; - } - return null; - } - - public void __setattr__(String name,PyObject value) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__setattr__"); - if (impl!=null) { - impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value); - return; - } - super.__setattr__(name,value); - } - - public void __delattr__(String name) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__delattr__"); - if (impl!=null) { - impl.__get__(this,self_type).__call__(PyString.fromInterned(name)); - return; - } - super.__delattr__(name); - } - - public PyObject __get__(PyObject obj,PyObject type) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__get__"); - if (impl!=null) { - if (obj==null) - obj=Py.None; - if (type==null) - type=Py.None; - return impl.__get__(this,self_type).__call__(obj,type); - } - return super.__get__(obj,type); - } - - public void __set__(PyObject obj,PyObject value) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__set__"); - if (impl!=null) { - impl.__get__(this,self_type).__call__(obj,value); - return; - } - super.__set__(obj,value); - } - - public void __delete__(PyObject obj) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__delete__"); - if (impl!=null) { - impl.__get__(this,self_type).__call__(obj); - return; - } - super.__delete__(obj); - } - - public PyObject __pow__(PyObject other,PyObject modulo) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__pow__"); - if (impl!=null) { - PyObject res; - if (modulo==null) { - res=impl.__get__(this,self_type).__call__(other); - } else { - res=impl.__get__(this,self_type).__call__(other,modulo); - } - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__pow__(other,modulo); - } - - public void dispatch__init__(PyType type,PyObject[]args,String[]keywords) { - PyType self_type=getType(); - if (self_type.isSubType(type)) { - PyObject impl=self_type.lookup("__init__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(args,keywords); - if (res!=Py.None) { - throw Py.TypeError(String.format("__init__() should return None, not '%.200s'",res.getType().fastGetName())); - } - proxyInit(); - } - } - } - - public PyObject __index__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__index__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyInteger||res instanceof PyLong) { - return res; - } - throw Py.TypeError(String.format("__index__ returned non-(int,long) (type %s)",res.getType().fastGetName())); - } - return super.__index__(); - } - - public Object __tojava__(Class c) { - // If we are not being asked by the "default" conversion to java, then - // we can provide this as the result, as long as it is a instance of the - // specified class. Without this, derived.__tojava__(PyObject.class) - // would broke. (And that's not pure speculation: PyReflectedFunction's - // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { - return this; - } - // Otherwise, we call the derived __tojava__, if it exists: - PyType self_type=getType(); - PyObject impl=self_type.lookup("__tojava__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(Py.java2py(c)).__tojava__(Object.class); - return super.__tojava__(c); - } - - public Object __coerce_ex__(PyObject o) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__coerce__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(o); - if (res==Py.NotImplemented) - return Py.None; - if (!(res instanceof PyTuple)) - throw Py.TypeError("__coerce__ didn't return a 2-tuple"); - return((PyTuple)res).getArray(); - } - return super.__coerce_ex__(o); - } - - public String toString() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__repr__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (!(res instanceof PyString)) - throw Py.TypeError("__repr__ returned non-string (type "+res.getType().fastGetName()+")"); - return((PyString)res).toString(); - } - return super.toString(); - } - -} Deleted: branches/jy3k/src/org/python/antlr/ast/PrintDerived.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/PrintDerived.java 2009-01-05 13:16:44 UTC (rev 5848) +++ branches/jy3k/src/org/python/antlr/ast/PrintDerived.java 2009-01-05 13:39:31 UTC (rev 5849) @@ -1,1163 +0,0 @@ -/* Generated file, do not modify. See jython/src/templates/gderived.py. */ -package org.python.antlr.ast; - -import java.io.Serializable; -import org.python.core.*; - -public class PrintDerived extends Print implements Slotted { - - public PyObject getSlot(int index) { - return slots[index]; - } - - public void setSlot(int index,PyObject value) { - slots[index]=value; - } - - private PyObject[]slots; - - private PyObject dict; - - public PyObject fastGetDict() { - return dict; - } - - public PyObject getDict() { - return dict; - } - - public void setDict(PyObject newDict) { - if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) { - dict=newDict; - } else { - throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName()); - } - } - - public void delDict() { - // deleting an object's instance dict makes it grow a new one - dict=new PyStringMap(); - } - - public PrintDerived(PyType subtype) { - super(subtype); - slots=new PyObject[subtype.getNumSlots()]; - dict=subtype.instDict(); - } - - public PyString __str__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__str__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyString) - return(PyString)res; - throw Py.TypeError("__str__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); - } - return super.__str__(); - } - - public PyString __repr__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__repr__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyString) - return(PyString)res; - throw Py.TypeError("__repr__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); - } - return super.__repr__(); - } - - public PyString __hex__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__hex__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyString) - return(PyString)res; - throw Py.TypeError("__hex__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); - } - return super.__hex__(); - } - - public PyString __oct__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__oct__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyString) - return(PyString)res; - throw Py.TypeError("__oct__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); - } - return super.__oct__(); - } - - public PyFloat __float__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__float__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyFloat) - return(PyFloat)res; - throw Py.TypeError("__float__"+" returned non-"+"float"+" (type "+res.getType().fastGetName()+")"); - } - return super.__float__(); - } - - public PyComplex __complex__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__complex__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyComplex) - return(PyComplex)res; - throw Py.TypeError("__complex__"+" returned non-"+"complex"+" (type "+res.getType().fastGetName()+")"); - } - return super.__complex__(); - } - - public PyObject __pos__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__pos__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__pos__(); - } - - public PyObject __neg__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__neg__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__neg__(); - } - - public PyObject __abs__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__abs__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__abs__(); - } - - public PyObject __invert__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__invert__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__invert__(); - } - - public PyObject __reduce__() { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__reduce__"); - if (impl!=null) - return impl.__get__(this,self_type).__call__(); - return super.__reduce__(); - } - - public PyObject __add__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__add__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__add__(other); - } - - public PyObject __radd__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__radd__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__radd__(other); - } - - public PyObject __sub__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__sub__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__sub__(other); - } - - public PyObject __rsub__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rsub__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rsub__(other); - } - - public PyObject __mul__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__mul__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__mul__(other); - } - - public PyObject __rmul__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rmul__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rmul__(other); - } - - public PyObject __div__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__div__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__div__(other); - } - - public PyObject __rdiv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rdiv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rdiv__(other); - } - - public PyObject __floordiv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__floordiv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__floordiv__(other); - } - - public PyObject __rfloordiv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rfloordiv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rfloordiv__(other); - } - - public PyObject __truediv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__truediv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__truediv__(other); - } - - public PyObject __rtruediv__(PyObject other) { - PyType self_type=getType(); - PyObject impl=self_type.lookup("__rtruediv__"); - if (impl!=null) { - PyObject res=impl.__get__(this,self_type).__call__(other); - if (res==Py.NotImplemented) - return null; - return res; - } - return super.__rtruediv__(other); - } - - public PyObject __mod__(PyObject other) { ... [truncated message content] |
From: <fwi...@us...> - 2009-01-05 13:16:51
|
Revision: 5848 http://jython.svn.sourceforge.net/jython/?rev=5848&view=rev Author: fwierzbicki Date: 2009-01-05 13:16:44 +0000 (Mon, 05 Jan 2009) Log Message: ----------- Initial switchover to 3.0 Python.asdl. Doesn't compiler yet. Modified Paths: -------------- branches/jy3k/ast/Python.asdl branches/jy3k/grammar/Python.g branches/jy3k/grammar/PythonPartial.g branches/jy3k/src/org/python/antlr/ast/ClassDef.java branches/jy3k/src/org/python/antlr/ast/Ellipsis.java branches/jy3k/src/org/python/antlr/ast/ExceptHandler.java branches/jy3k/src/org/python/antlr/ast/FunctionDef.java branches/jy3k/src/org/python/antlr/ast/Raise.java branches/jy3k/src/org/python/antlr/ast/VisitorBase.java branches/jy3k/src/org/python/antlr/ast/VisitorIF.java branches/jy3k/src/org/python/antlr/ast/arguments.java Added Paths: ----------- branches/jy3k/src/org/python/antlr/ast/Bytes.java branches/jy3k/src/org/python/antlr/ast/DictComp.java branches/jy3k/src/org/python/antlr/ast/Nonlocal.java branches/jy3k/src/org/python/antlr/ast/Set.java branches/jy3k/src/org/python/antlr/ast/SetComp.java branches/jy3k/src/org/python/antlr/ast/Starred.java branches/jy3k/src/org/python/antlr/ast/arg.java Removed Paths: ------------- branches/jy3k/src/org/python/antlr/ast/Exec.java branches/jy3k/src/org/python/antlr/ast/Print.java branches/jy3k/src/org/python/antlr/ast/Repr.java Modified: branches/jy3k/ast/Python.asdl =================================================================== --- branches/jy3k/ast/Python.asdl 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/ast/Python.asdl 2009-01-05 13:16:44 UTC (rev 5848) @@ -1,6 +1,6 @@ --- ASDL's five builtin types are identifier, int, string, object, bool +-- ASDL's four builtin types are identifier, int, string, object -module Python version "$Revision: 62047 $" +module Python version "$Revision: 67616 $" { mod = Module(stmt* body) | Interactive(stmt* body) @@ -10,26 +10,27 @@ | Suite(stmt* body) stmt = FunctionDef(identifier name, arguments args, - stmt* body, expr* decorator_list) - | ClassDef(identifier name, expr* bases, stmt* body, expr *decorator_list) + stmt* body, expr* decorator_list, expr? returns) + | ClassDef(identifier name, + expr* bases, + keyword* keywords, + expr? starargs, + expr? kwargs, + stmt* body, + expr *decorator_list) | Return(expr? value) | Delete(expr* targets) | Assign(expr* targets, expr value) | AugAssign(expr target, operator op, expr value) - -- not sure if bool is allowed, can always use int - | Print(expr? dest, expr* values, bool nl) - -- use 'orelse' because else is a keyword in target languages | For(expr target, expr iter, stmt* body, stmt* orelse) | While(expr test, stmt* body, stmt* orelse) | If(expr test, stmt* body, stmt* orelse) | With(expr context_expr, expr? optional_vars, stmt* body) - -- 'type' is a bad name - -- changed to 'type' to excepttype for Jython - | Raise(expr? excepttype, expr? inst, expr? tback) + | Raise(expr? exc, expr? cause) | TryExcept(stmt* body, excepthandler* handlers, stmt* orelse) | TryFinally(stmt* body, stmt* finalbody) | Assert(expr test, expr? msg) @@ -37,12 +38,8 @@ | Import(alias* names) | ImportFrom(identifier module, alias* names, int? level) - -- Doesn't capture requirement that locals must be - -- defined if globals is - -- still supports use as a function! - | Exec(expr body, expr? globals, expr? locals) - | Global(identifier* names) + | Nonlocal(identifier* names) | Expr(expr value) | Pass | Break | Continue @@ -57,7 +54,10 @@ | Lambda(arguments args, expr body) | IfExp(expr test, expr body, expr orelse) | Dict(expr* keys, expr* values) + | Set(expr* elts) | ListComp(expr elt, comprehension* generators) + | SetComp(expr elt, comprehension* generators) + | DictComp(expr key, expr value, comprehension* generators) | GeneratorExp(expr elt, comprehension* generators) -- the grammar constrains where yield expressions can occur | Yield(expr? value) @@ -66,14 +66,16 @@ | Compare(expr left, cmpop* ops, expr* comparators) | Call(expr func, expr* args, keyword* keywords, expr? starargs, expr? kwargs) - | Repr(expr value) | Num(object n) -- a number as a PyObject. | Str(string s) -- need to specify raw, unicode, etc? + | Bytes(string s) + | Ellipsis -- other literals? bools? -- the following expression can appear in assignment context | Attribute(expr value, identifier attr, expr_context ctx) | Subscript(expr value, slice slice, expr_context ctx) + | Starred(expr value, expr_context ctx) | Name(identifier id, expr_context ctx) | List(expr* elts, expr_context ctx) | Tuple(expr* elts, expr_context ctx) @@ -83,7 +85,7 @@ expr_context = Load | Store | Del | AugLoad | AugStore | Param - slice = Ellipsis | Slice(expr? lower, expr? upper, expr? step) + slice = Slice(expr? lower, expr? upper, expr? step) | ExtSlice(slice* dims) | Index(expr value) @@ -100,11 +102,14 @@ -- not sure what to call the first argument for raise and except -- changed to 'type' to excepttype for Jython - excepthandler = ExceptHandler(expr? excepttype, expr? name, stmt* body) + excepthandler = ExceptHandler(expr? excepttype, identifier? name, stmt* body) attributes (int lineno, int col_offset) - arguments = (expr* args, identifier? vararg, - identifier? kwarg, expr* defaults) + arguments = (arg* args, identifier? vararg, expr? varargannotation, + arg* kwonlyargs, identifier? kwarg, + expr? kwargannotation, expr* defaults, + expr* kw_defaults) + arg = (identifier arg, expr? annotation) -- keyword arguments supplied to call keyword = (identifier arg, expr value) @@ -112,3 +117,4 @@ -- import name with optional 'as' alias. alias = (identifier name, identifier? asname) } + Modified: branches/jy3k/grammar/Python.g =================================================================== --- branches/jy3k/grammar/Python.g 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/grammar/Python.g 2009-01-05 13:16:44 UTC (rev 5848) @@ -105,7 +105,6 @@ import org.python.antlr.ast.Ellipsis; import org.python.antlr.ast.ErrorMod; import org.python.antlr.ast.ExceptHandler; -import org.python.antlr.ast.Exec; import org.python.antlr.ast.Expr; import org.python.antlr.ast.Expression; import org.python.antlr.ast.expr_contextType; @@ -127,7 +126,6 @@ import org.python.antlr.ast.Num; import org.python.antlr.ast.operatorType; import org.python.antlr.ast.Pass; -import org.python.antlr.ast.Print; import org.python.antlr.ast.Raise; import org.python.antlr.ast.Repr; import org.python.antlr.ast.Return; @@ -393,7 +391,6 @@ | OR | ORELSE | PASS - | PRINT | RAISE | RETURN | TRY @@ -545,13 +542,11 @@ //small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | // import_stmt | global_stmt | exec_stmt | assert_stmt) small_stmt : expr_stmt - | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt - | exec_stmt | assert_stmt ; @@ -615,60 +610,6 @@ | DOUBLESLASHEQUAL {$op = operatorType.FloorDiv;} ; -//print_stmt: 'print' ( [ test (',' test)* [','] ] | -// '>>' test [ (',' test)+ [','] ] ) -print_stmt - : PRINT - (t1=printlist - -> ^(PRINT<Print>[$PRINT, null, actions.castExprs($t1.elts), $t1.newline]) - | RIGHTSHIFT t2=printlist2 - -> ^(PRINT<Print>[$PRINT, actions.castExpr($t2.elts.get(0)), actions.castExprs($t2.elts, 1), $t2.newline]) - | - -> ^(PRINT<Print>[$PRINT, null, new ArrayList<expr>(), false]) - ) - ; - -//not in CPython's Grammar file -printlist returns [boolean newline, List elts] - : (test[null] COMMA) => - t+=test[expr_contextType.Load] (options {k=2;}: COMMA t+=test[expr_contextType.Load])* - (trailcomma=COMMA)? - { - $elts=$t; - if ($trailcomma == null) { - $newline = true; - } else { - $newline = false; - } - } - | t+=test[expr_contextType.Load] - { - $elts=$t; - $newline = true; - } - ; - -//XXX: would be nice if printlist and printlist2 could be merged. -//not in CPython's Grammar file -printlist2 returns [boolean newline, List elts] - : (test[null] COMMA test[null]) => - t+=test[expr_contextType.Load] (options {k=2;}: COMMA t+=test[expr_contextType.Load])* - (trailcomma=COMMA)? - { $elts=$t; - if ($trailcomma == null) { - $newline = true; - } else { - $newline = false; - } - } - | t+=test[expr_contextType.Load] - { - $elts=$t; - $newline = true; - } - ; - - //del_stmt: 'del' exprlist del_stmt : DELETE del_list @@ -807,21 +748,6 @@ -> ^(GLOBAL<Global>[$GLOBAL, actions.makeNames($n)]) ; -//exec_stmt: 'exec' expr ['in' test [',' test]] -exec_stmt -@init { - stmt stype = null; -} -@after { - $exec_stmt.tree = stype; -} - : EXEC expr[expr_contextType.Load] (IN t1=test[expr_contextType.Load] - (COMMA t2=test[expr_contextType.Load])?)? - { - stype = new Exec($EXEC, actions.castExpr($expr.tree), actions.castExpr($t1.tree), actions.castExpr($t2.tree)); - } - ; - //assert_stmt: 'assert' test [',' test] assert_stmt : ASSERT t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])? @@ -1619,7 +1545,6 @@ LAMBDA : 'lambda' ; ORELSE : 'else' ; PASS : 'pass' ; -PRINT : 'print' ; RAISE : 'raise' ; RETURN : 'return' ; TRY : 'try' ; Modified: branches/jy3k/grammar/PythonPartial.g =================================================================== --- branches/jy3k/grammar/PythonPartial.g 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/grammar/PythonPartial.g 2009-01-05 13:16:44 UTC (rev 5848) @@ -152,13 +152,11 @@ ; small_stmt : expr_stmt - | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt - | exec_stmt | assert_stmt ; @@ -196,13 +194,6 @@ | DOUBLESLASHEQUAL ; -print_stmt : PRINT (printlist | RIGHTSHIFT printlist)? - ; - -printlist returns [boolean newline] - : test (options {k=2;}: COMMA test)* (COMMA)? - ; - del_stmt : DELETE exprlist ; @@ -262,9 +253,6 @@ global_stmt : GLOBAL NAME (COMMA NAME)* ; -exec_stmt : EXEC expr (IN test (COMMA test)?)? - ; - assert_stmt : ASSERT test (COMMA test)? ; Added: branches/jy3k/src/org/python/antlr/ast/Bytes.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/Bytes.java (rev 0) +++ branches/jy3k/src/org/python/antlr/ast/Bytes.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -0,0 +1,147 @@ +// Autogenerated AST node +package org.python.antlr.ast; +import org.antlr.runtime.CommonToken; +import org.antlr.runtime.Token; +import org.python.antlr.AST; +import org.python.antlr.PythonTree; +import org.python.antlr.adapter.AstAdapters; +import org.python.antlr.base.excepthandler; +import org.python.antlr.base.expr; +import org.python.antlr.base.mod; +import org.python.antlr.base.slice; +import org.python.antlr.base.stmt; +import org.python.core.ArgParser; +import org.python.core.AstList; +import org.python.core.Py; +import org.python.core.PyObject; +import org.python.core.PyString; +import org.python.core.PyType; +import org.python.expose.ExposedGet; +import org.python.expose.ExposedMethod; +import org.python.expose.ExposedNew; +import org.python.expose.ExposedSet; +import org.python.expose.ExposedType; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; + +@ExposedType(name = "_ast.Bytes", base = AST.class) +public class Bytes extends expr { +public static final PyType TYPE = PyType.fromClass(Bytes.class); + private Object s; + public Object getInternalS() { + return s; + } + @ExposedGet(name = "s") + public PyObject getS() { + return (PyObject)s; + } + @ExposedSet(name = "s") + public void setS(PyObject s) { + this.s = AstAdapters.py2string(s); + } + + + private final static PyString[] fields = + new PyString[] {new PyString("s")}; + @ExposedGet(name = "_fields") + public PyString[] get_fields() { return fields; } + + private final static PyString[] attributes = + new PyString[] {new PyString("lineno"), new PyString("col_offset")}; + @ExposedGet(name = "_attributes") + public PyString[] get_attributes() { return attributes; } + + public Bytes(PyType subType) { + super(subType); + } + public Bytes() { + this(TYPE); + } + @ExposedNew + @ExposedMethod + public void Bytes___init__(PyObject[] args, String[] keywords) { + ArgParser ap = new ArgParser("Bytes", args, keywords, new String[] + {"s", "lineno", "col_offset"}, 1); + setS(ap.getPyObject(0)); + int lin = ap.getInt(1, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(2, -1); + if (col != -1) { + setLineno(col); + } + + } + + public Bytes(PyObject s) { + setS(s); + } + + public Bytes(Token token, Object s) { + super(token); + this.s = s; + } + + public Bytes(Integer ttype, Token token, Object s) { + super(ttype, token); + this.s = s; + } + + public Bytes(PythonTree tree, Object s) { + super(tree); + this.s = s; + } + + @ExposedGet(name = "repr") + public String toString() { + return "Bytes"; + } + + public String toStringTree() { + StringBuffer sb = new StringBuffer("Bytes("); + sb.append("s="); + sb.append(dumpThis(s)); + sb.append(","); + sb.append(")"); + return sb.toString(); + } + + public <R> R accept(VisitorIF<R> visitor) throws Exception { + return visitor.visitBytes(this); + } + + public void traverse(VisitorIF visitor) throws Exception { + } + + private int lineno = -1; + @ExposedGet(name = "lineno") + public int getLineno() { + if (lineno != -1) { + return lineno; + } + return getLine(); + } + + @ExposedSet(name = "lineno") + public void setLineno(int num) { + lineno = num; + } + + private int col_offset = -1; + @ExposedGet(name = "col_offset") + public int getCol_offset() { + if (col_offset != -1) { + return col_offset; + } + return getCharPositionInLine(); + } + + @ExposedSet(name = "col_offset") + public void setCol_offset(int num) { + col_offset = num; + } + +} Modified: branches/jy3k/src/org/python/antlr/ast/ClassDef.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/ClassDef.java 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/src/org/python/antlr/ast/ClassDef.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -55,6 +55,45 @@ this.bases = AstAdapters.py2exprList(bases); } + private java.util.List<keyword> keywords; + public java.util.List<keyword> getInternalKeywords() { + return keywords; + } + @ExposedGet(name = "keywords") + public PyObject getKeywords() { + return new AstList(keywords, AstAdapters.keywordAdapter); + } + @ExposedSet(name = "keywords") + public void setKeywords(PyObject keywords) { + this.keywords = AstAdapters.py2keywordList(keywords); + } + + private expr starargs; + public expr getInternalStarargs() { + return starargs; + } + @ExposedGet(name = "starargs") + public PyObject getStarargs() { + return starargs; + } + @ExposedSet(name = "starargs") + public void setStarargs(PyObject starargs) { + this.starargs = AstAdapters.py2expr(starargs); + } + + private expr kwargs; + public expr getInternalKwargs() { + return kwargs; + } + @ExposedGet(name = "kwargs") + public PyObject getKwargs() { + return kwargs; + } + @ExposedSet(name = "kwargs") + public void setKwargs(PyObject kwargs) { + this.kwargs = AstAdapters.py2expr(kwargs); + } + private java.util.List<stmt> body; public java.util.List<stmt> getInternalBody() { return body; @@ -83,7 +122,8 @@ private final static PyString[] fields = - new PyString[] {new PyString("name"), new PyString("bases"), new PyString("body"), new + new PyString[] {new PyString("name"), new PyString("bases"), new PyString("keywords"), new + PyString("starargs"), new PyString("kwargs"), new PyString("body"), new PyString("decorator_list")}; @ExposedGet(name = "_fields") public PyString[] get_fields() { return fields; } @@ -103,32 +143,41 @@ @ExposedMethod public void ClassDef___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("ClassDef", args, keywords, new String[] - {"name", "bases", "body", "decorator_list", "lineno", "col_offset"}, 4); + {"name", "bases", "keywords", "starargs", "kwargs", "body", "decorator_list", "lineno", + "col_offset"}, 7); setName(ap.getPyObject(0)); setBases(ap.getPyObject(1)); - setBody(ap.getPyObject(2)); - setDecorator_list(ap.getPyObject(3)); - int lin = ap.getInt(4, -1); + setKeywords(ap.getPyObject(2)); + setStarargs(ap.getPyObject(3)); + setKwargs(ap.getPyObject(4)); + setBody(ap.getPyObject(5)); + setDecorator_list(ap.getPyObject(6)); + int lin = ap.getInt(7, -1); if (lin != -1) { setLineno(lin); } - int col = ap.getInt(5, -1); + int col = ap.getInt(8, -1); if (col != -1) { setLineno(col); } } - public ClassDef(PyObject name, PyObject bases, PyObject body, PyObject decorator_list) { + public ClassDef(PyObject name, PyObject bases, PyObject keywords, PyObject starargs, PyObject + kwargs, PyObject body, PyObject decorator_list) { setName(name); setBases(bases); + setKeywords(keywords); + setStarargs(starargs); + setKwargs(kwargs); setBody(body); setDecorator_list(decorator_list); } - public ClassDef(Token token, String name, java.util.List<expr> bases, java.util.List<stmt> - body, java.util.List<expr> decorator_list) { + public ClassDef(Token token, String name, java.util.List<expr> bases, java.util.List<keyword> + keywords, expr starargs, expr kwargs, java.util.List<stmt> body, java.util.List<expr> + decorator_list) { super(token); this.name = name; this.bases = bases; @@ -138,6 +187,17 @@ for(PythonTree t : this.bases) { addChild(t); } + this.keywords = keywords; + if (keywords == null) { + this.keywords = new ArrayList<keyword>(); + } + for(PythonTree t : this.keywords) { + addChild(t); + } + this.starargs = starargs; + addChild(starargs); + this.kwargs = kwargs; + addChild(kwargs); this.body = body; if (body == null) { this.body = new ArrayList<stmt>(); @@ -155,7 +215,8 @@ } public ClassDef(Integer ttype, Token token, String name, java.util.List<expr> bases, - java.util.List<stmt> body, java.util.List<expr> decorator_list) { + java.util.List<keyword> keywords, expr starargs, expr kwargs, java.util.List<stmt> body, + java.util.List<expr> decorator_list) { super(ttype, token); this.name = name; this.bases = bases; @@ -165,6 +226,17 @@ for(PythonTree t : this.bases) { addChild(t); } + this.keywords = keywords; + if (keywords == null) { + this.keywords = new ArrayList<keyword>(); + } + for(PythonTree t : this.keywords) { + addChild(t); + } + this.starargs = starargs; + addChild(starargs); + this.kwargs = kwargs; + addChild(kwargs); this.body = body; if (body == null) { this.body = new ArrayList<stmt>(); @@ -181,8 +253,9 @@ } } - public ClassDef(PythonTree tree, String name, java.util.List<expr> bases, java.util.List<stmt> - body, java.util.List<expr> decorator_list) { + public ClassDef(PythonTree tree, String name, java.util.List<expr> bases, + java.util.List<keyword> keywords, expr starargs, expr kwargs, java.util.List<stmt> body, + java.util.List<expr> decorator_list) { super(tree); this.name = name; this.bases = bases; @@ -192,6 +265,17 @@ for(PythonTree t : this.bases) { addChild(t); } + this.keywords = keywords; + if (keywords == null) { + this.keywords = new ArrayList<keyword>(); + } + for(PythonTree t : this.keywords) { + addChild(t); + } + this.starargs = starargs; + addChild(starargs); + this.kwargs = kwargs; + addChild(kwargs); this.body = body; if (body == null) { this.body = new ArrayList<stmt>(); @@ -221,6 +305,15 @@ sb.append("bases="); sb.append(dumpThis(bases)); sb.append(","); + sb.append("keywords="); + sb.append(dumpThis(keywords)); + sb.append(","); + sb.append("starargs="); + sb.append(dumpThis(starargs)); + sb.append(","); + sb.append("kwargs="); + sb.append(dumpThis(kwargs)); + sb.append(","); sb.append("body="); sb.append(dumpThis(body)); sb.append(","); @@ -242,6 +335,16 @@ t.accept(visitor); } } + if (keywords != null) { + for (PythonTree t : keywords) { + if (t != null) + t.accept(visitor); + } + } + if (starargs != null) + starargs.accept(visitor); + if (kwargs != null) + kwargs.accept(visitor); if (body != null) { for (PythonTree t : body) { if (t != null) Added: branches/jy3k/src/org/python/antlr/ast/DictComp.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/DictComp.java (rev 0) +++ branches/jy3k/src/org/python/antlr/ast/DictComp.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -0,0 +1,225 @@ +// Autogenerated AST node +package org.python.antlr.ast; +import org.antlr.runtime.CommonToken; +import org.antlr.runtime.Token; +import org.python.antlr.AST; +import org.python.antlr.PythonTree; +import org.python.antlr.adapter.AstAdapters; +import org.python.antlr.base.excepthandler; +import org.python.antlr.base.expr; +import org.python.antlr.base.mod; +import org.python.antlr.base.slice; +import org.python.antlr.base.stmt; +import org.python.core.ArgParser; +import org.python.core.AstList; +import org.python.core.Py; +import org.python.core.PyObject; +import org.python.core.PyString; +import org.python.core.PyType; +import org.python.expose.ExposedGet; +import org.python.expose.ExposedMethod; +import org.python.expose.ExposedNew; +import org.python.expose.ExposedSet; +import org.python.expose.ExposedType; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; + +@ExposedType(name = "_ast.DictComp", base = AST.class) +public class DictComp extends expr { +public static final PyType TYPE = PyType.fromClass(DictComp.class); + private expr key; + public expr getInternalKey() { + return key; + } + @ExposedGet(name = "key") + public PyObject getKey() { + return key; + } + @ExposedSet(name = "key") + public void setKey(PyObject key) { + this.key = AstAdapters.py2expr(key); + } + + private expr value; + public expr getInternalValue() { + return value; + } + @ExposedGet(name = "value") + public PyObject getValue() { + return value; + } + @ExposedSet(name = "value") + public void setValue(PyObject value) { + this.value = AstAdapters.py2expr(value); + } + + private java.util.List<comprehension> generators; + public java.util.List<comprehension> getInternalGenerators() { + return generators; + } + @ExposedGet(name = "generators") + public PyObject getGenerators() { + return new AstList(generators, AstAdapters.comprehensionAdapter); + } + @ExposedSet(name = "generators") + public void setGenerators(PyObject generators) { + this.generators = AstAdapters.py2comprehensionList(generators); + } + + + private final static PyString[] fields = + new PyString[] {new PyString("key"), new PyString("value"), new PyString("generators")}; + @ExposedGet(name = "_fields") + public PyString[] get_fields() { return fields; } + + private final static PyString[] attributes = + new PyString[] {new PyString("lineno"), new PyString("col_offset")}; + @ExposedGet(name = "_attributes") + public PyString[] get_attributes() { return attributes; } + + public DictComp(PyType subType) { + super(subType); + } + public DictComp() { + this(TYPE); + } + @ExposedNew + @ExposedMethod + public void DictComp___init__(PyObject[] args, String[] keywords) { + ArgParser ap = new ArgParser("DictComp", args, keywords, new String[] + {"key", "value", "generators", "lineno", "col_offset"}, 3); + setKey(ap.getPyObject(0)); + setValue(ap.getPyObject(1)); + setGenerators(ap.getPyObject(2)); + int lin = ap.getInt(3, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(4, -1); + if (col != -1) { + setLineno(col); + } + + } + + public DictComp(PyObject key, PyObject value, PyObject generators) { + setKey(key); + setValue(value); + setGenerators(generators); + } + + public DictComp(Token token, expr key, expr value, java.util.List<comprehension> generators) { + super(token); + this.key = key; + addChild(key); + this.value = value; + addChild(value); + this.generators = generators; + if (generators == null) { + this.generators = new ArrayList<comprehension>(); + } + for(PythonTree t : this.generators) { + addChild(t); + } + } + + public DictComp(Integer ttype, Token token, expr key, expr value, java.util.List<comprehension> + generators) { + super(ttype, token); + this.key = key; + addChild(key); + this.value = value; + addChild(value); + this.generators = generators; + if (generators == null) { + this.generators = new ArrayList<comprehension>(); + } + for(PythonTree t : this.generators) { + addChild(t); + } + } + + public DictComp(PythonTree tree, expr key, expr value, java.util.List<comprehension> + generators) { + super(tree); + this.key = key; + addChild(key); + this.value = value; + addChild(value); + this.generators = generators; + if (generators == null) { + this.generators = new ArrayList<comprehension>(); + } + for(PythonTree t : this.generators) { + addChild(t); + } + } + + @ExposedGet(name = "repr") + public String toString() { + return "DictComp"; + } + + public String toStringTree() { + StringBuffer sb = new StringBuffer("DictComp("); + sb.append("key="); + sb.append(dumpThis(key)); + sb.append(","); + sb.append("value="); + sb.append(dumpThis(value)); + sb.append(","); + sb.append("generators="); + sb.append(dumpThis(generators)); + sb.append(","); + sb.append(")"); + return sb.toString(); + } + + public <R> R accept(VisitorIF<R> visitor) throws Exception { + return visitor.visitDictComp(this); + } + + public void traverse(VisitorIF visitor) throws Exception { + if (key != null) + key.accept(visitor); + if (value != null) + value.accept(visitor); + if (generators != null) { + for (PythonTree t : generators) { + if (t != null) + t.accept(visitor); + } + } + } + + private int lineno = -1; + @ExposedGet(name = "lineno") + public int getLineno() { + if (lineno != -1) { + return lineno; + } + return getLine(); + } + + @ExposedSet(name = "lineno") + public void setLineno(int num) { + lineno = num; + } + + private int col_offset = -1; + @ExposedGet(name = "col_offset") + public int getCol_offset() { + if (col_offset != -1) { + return col_offset; + } + return getCharPositionInLine(); + } + + @ExposedSet(name = "col_offset") + public void setCol_offset(int num) { + col_offset = num; + } + +} Modified: branches/jy3k/src/org/python/antlr/ast/Ellipsis.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/Ellipsis.java 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/src/org/python/antlr/ast/Ellipsis.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -26,14 +26,15 @@ import java.util.ArrayList; @ExposedType(name = "_ast.Ellipsis", base = AST.class) -public class Ellipsis extends slice { +public class Ellipsis extends expr { public static final PyType TYPE = PyType.fromClass(Ellipsis.class); private final static PyString[] fields = new PyString[0]; @ExposedGet(name = "_fields") public PyString[] get_fields() { return fields; } - private final static PyString[] attributes = new PyString[0]; + private final static PyString[] attributes = + new PyString[] {new PyString("lineno"), new PyString("col_offset")}; @ExposedGet(name = "_attributes") public PyString[] get_attributes() { return attributes; } @@ -44,7 +45,17 @@ @ExposedMethod public void Ellipsis___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Ellipsis", args, keywords, new String[] - {}, 0); + {"lineno", "col_offset"}, 0); + int lin = ap.getInt(0, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(1, -1); + if (col != -1) { + setLineno(col); + } + } public Ellipsis() { @@ -80,4 +91,32 @@ public void traverse(VisitorIF visitor) throws Exception { } + private int lineno = -1; + @ExposedGet(name = "lineno") + public int getLineno() { + if (lineno != -1) { + return lineno; + } + return getLine(); + } + + @ExposedSet(name = "lineno") + public void setLineno(int num) { + lineno = num; + } + + private int col_offset = -1; + @ExposedGet(name = "col_offset") + public int getCol_offset() { + if (col_offset != -1) { + return col_offset; + } + return getCharPositionInLine(); + } + + @ExposedSet(name = "col_offset") + public void setCol_offset(int num) { + col_offset = num; + } + } Modified: branches/jy3k/src/org/python/antlr/ast/ExceptHandler.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/ExceptHandler.java 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/src/org/python/antlr/ast/ExceptHandler.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -41,17 +41,18 @@ this.excepttype = AstAdapters.py2expr(excepttype); } - private expr name; - public expr getInternalName() { + private String name; + public String getInternalName() { return name; } @ExposedGet(name = "name") public PyObject getName() { - return name; + if (name == null) return Py.None; + return new PyString(name); } @ExposedSet(name = "name") public void setName(PyObject name) { - this.name = AstAdapters.py2expr(name); + this.name = AstAdapters.py2identifier(name); } private java.util.List<stmt> body; @@ -110,12 +111,11 @@ setBody(body); } - public ExceptHandler(Token token, expr excepttype, expr name, java.util.List<stmt> body) { + public ExceptHandler(Token token, expr excepttype, String name, java.util.List<stmt> body) { super(token); this.excepttype = excepttype; addChild(excepttype); this.name = name; - addChild(name); this.body = body; if (body == null) { this.body = new ArrayList<stmt>(); @@ -125,13 +125,12 @@ } } - public ExceptHandler(Integer ttype, Token token, expr excepttype, expr name, + public ExceptHandler(Integer ttype, Token token, expr excepttype, String name, java.util.List<stmt> body) { super(ttype, token); this.excepttype = excepttype; addChild(excepttype); this.name = name; - addChild(name); this.body = body; if (body == null) { this.body = new ArrayList<stmt>(); @@ -141,12 +140,11 @@ } } - public ExceptHandler(PythonTree tree, expr excepttype, expr name, java.util.List<stmt> body) { + public ExceptHandler(PythonTree tree, expr excepttype, String name, java.util.List<stmt> body) { super(tree); this.excepttype = excepttype; addChild(excepttype); this.name = name; - addChild(name); this.body = body; if (body == null) { this.body = new ArrayList<stmt>(); @@ -183,8 +181,6 @@ public void traverse(VisitorIF visitor) throws Exception { if (excepttype != null) excepttype.accept(visitor); - if (name != null) - name.accept(visitor); if (body != null) { for (PythonTree t : body) { if (t != null) Deleted: branches/jy3k/src/org/python/antlr/ast/Exec.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/Exec.java 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/src/org/python/antlr/ast/Exec.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -1,204 +0,0 @@ -// Autogenerated AST node -package org.python.antlr.ast; -import org.antlr.runtime.CommonToken; -import org.antlr.runtime.Token; -import org.python.antlr.AST; -import org.python.antlr.PythonTree; -import org.python.antlr.adapter.AstAdapters; -import org.python.antlr.base.excepthandler; -import org.python.antlr.base.expr; -import org.python.antlr.base.mod; -import org.python.antlr.base.slice; -import org.python.antlr.base.stmt; -import org.python.core.ArgParser; -import org.python.core.AstList; -import org.python.core.Py; -import org.python.core.PyObject; -import org.python.core.PyString; -import org.python.core.PyType; -import org.python.expose.ExposedGet; -import org.python.expose.ExposedMethod; -import org.python.expose.ExposedNew; -import org.python.expose.ExposedSet; -import org.python.expose.ExposedType; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.ArrayList; - -@ExposedType(name = "_ast.Exec", base = AST.class) -public class Exec extends stmt { -public static final PyType TYPE = PyType.fromClass(Exec.class); - private expr body; - public expr getInternalBody() { - return body; - } - @ExposedGet(name = "body") - public PyObject getBody() { - return body; - } - @ExposedSet(name = "body") - public void setBody(PyObject body) { - this.body = AstAdapters.py2expr(body); - } - - private expr globals; - public expr getInternalGlobals() { - return globals; - } - @ExposedGet(name = "globals") - public PyObject getGlobals() { - return globals; - } - @ExposedSet(name = "globals") - public void setGlobals(PyObject globals) { - this.globals = AstAdapters.py2expr(globals); - } - - private expr locals; - public expr getInternalLocals() { - return locals; - } - @ExposedGet(name = "locals") - public PyObject getLocals() { - return locals; - } - @ExposedSet(name = "locals") - public void setLocals(PyObject locals) { - this.locals = AstAdapters.py2expr(locals); - } - - - private final static PyString[] fields = - new PyString[] {new PyString("body"), new PyString("globals"), new PyString("locals")}; - @ExposedGet(name = "_fields") - public PyString[] get_fields() { return fields; } - - private final static PyString[] attributes = - new PyString[] {new PyString("lineno"), new PyString("col_offset")}; - @ExposedGet(name = "_attributes") - public PyString[] get_attributes() { return attributes; } - - public Exec(PyType subType) { - super(subType); - } - public Exec() { - this(TYPE); - } - @ExposedNew - @ExposedMethod - public void Exec___init__(PyObject[] args, String[] keywords) { - ArgParser ap = new ArgParser("Exec", args, keywords, new String[] - {"body", "globals", "locals", "lineno", "col_offset"}, 3); - setBody(ap.getPyObject(0)); - setGlobals(ap.getPyObject(1)); - setLocals(ap.getPyObject(2)); - int lin = ap.getInt(3, -1); - if (lin != -1) { - setLineno(lin); - } - - int col = ap.getInt(4, -1); - if (col != -1) { - setLineno(col); - } - - } - - public Exec(PyObject body, PyObject globals, PyObject locals) { - setBody(body); - setGlobals(globals); - setLocals(locals); - } - - public Exec(Token token, expr body, expr globals, expr locals) { - super(token); - this.body = body; - addChild(body); - this.globals = globals; - addChild(globals); - this.locals = locals; - addChild(locals); - } - - public Exec(Integer ttype, Token token, expr body, expr globals, expr locals) { - super(ttype, token); - this.body = body; - addChild(body); - this.globals = globals; - addChild(globals); - this.locals = locals; - addChild(locals); - } - - public Exec(PythonTree tree, expr body, expr globals, expr locals) { - super(tree); - this.body = body; - addChild(body); - this.globals = globals; - addChild(globals); - this.locals = locals; - addChild(locals); - } - - @ExposedGet(name = "repr") - public String toString() { - return "Exec"; - } - - public String toStringTree() { - StringBuffer sb = new StringBuffer("Exec("); - sb.append("body="); - sb.append(dumpThis(body)); - sb.append(","); - sb.append("globals="); - sb.append(dumpThis(globals)); - sb.append(","); - sb.append("locals="); - sb.append(dumpThis(locals)); - sb.append(","); - sb.append(")"); - return sb.toString(); - } - - public <R> R accept(VisitorIF<R> visitor) throws Exception { - return visitor.visitExec(this); - } - - public void traverse(VisitorIF visitor) throws Exception { - if (body != null) - body.accept(visitor); - if (globals != null) - globals.accept(visitor); - if (locals != null) - locals.accept(visitor); - } - - private int lineno = -1; - @ExposedGet(name = "lineno") - public int getLineno() { - if (lineno != -1) { - return lineno; - } - return getLine(); - } - - @ExposedSet(name = "lineno") - public void setLineno(int num) { - lineno = num; - } - - private int col_offset = -1; - @ExposedGet(name = "col_offset") - public int getCol_offset() { - if (col_offset != -1) { - return col_offset; - } - return getCharPositionInLine(); - } - - @ExposedSet(name = "col_offset") - public void setCol_offset(int num) { - col_offset = num; - } - -} Modified: branches/jy3k/src/org/python/antlr/ast/FunctionDef.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/FunctionDef.java 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/src/org/python/antlr/ast/FunctionDef.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -81,10 +81,23 @@ this.decorator_list = AstAdapters.py2exprList(decorator_list); } + private expr returns; + public expr getInternalReturns() { + return returns; + } + @ExposedGet(name = "returns") + public PyObject getReturns() { + return returns; + } + @ExposedSet(name = "returns") + public void setReturns(PyObject returns) { + this.returns = AstAdapters.py2expr(returns); + } + private final static PyString[] fields = new PyString[] {new PyString("name"), new PyString("args"), new PyString("body"), new - PyString("decorator_list")}; + PyString("decorator_list"), new PyString("returns")}; @ExposedGet(name = "_fields") public PyString[] get_fields() { return fields; } @@ -103,32 +116,35 @@ @ExposedMethod public void FunctionDef___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("FunctionDef", args, keywords, new String[] - {"name", "args", "body", "decorator_list", "lineno", "col_offset"}, 4); + {"name", "args", "body", "decorator_list", "returns", "lineno", "col_offset"}, 5); setName(ap.getPyObject(0)); setArgs(ap.getPyObject(1)); setBody(ap.getPyObject(2)); setDecorator_list(ap.getPyObject(3)); - int lin = ap.getInt(4, -1); + setReturns(ap.getPyObject(4)); + int lin = ap.getInt(5, -1); if (lin != -1) { setLineno(lin); } - int col = ap.getInt(5, -1); + int col = ap.getInt(6, -1); if (col != -1) { setLineno(col); } } - public FunctionDef(PyObject name, PyObject args, PyObject body, PyObject decorator_list) { + public FunctionDef(PyObject name, PyObject args, PyObject body, PyObject decorator_list, + PyObject returns) { setName(name); setArgs(args); setBody(body); setDecorator_list(decorator_list); + setReturns(returns); } public FunctionDef(Token token, String name, arguments args, java.util.List<stmt> body, - java.util.List<expr> decorator_list) { + java.util.List<expr> decorator_list, expr returns) { super(token); this.name = name; this.args = args; @@ -146,10 +162,12 @@ for(PythonTree t : this.decorator_list) { addChild(t); } + this.returns = returns; + addChild(returns); } public FunctionDef(Integer ttype, Token token, String name, arguments args, - java.util.List<stmt> body, java.util.List<expr> decorator_list) { + java.util.List<stmt> body, java.util.List<expr> decorator_list, expr returns) { super(ttype, token); this.name = name; this.args = args; @@ -167,10 +185,12 @@ for(PythonTree t : this.decorator_list) { addChild(t); } + this.returns = returns; + addChild(returns); } public FunctionDef(PythonTree tree, String name, arguments args, java.util.List<stmt> body, - java.util.List<expr> decorator_list) { + java.util.List<expr> decorator_list, expr returns) { super(tree); this.name = name; this.args = args; @@ -188,6 +208,8 @@ for(PythonTree t : this.decorator_list) { addChild(t); } + this.returns = returns; + addChild(returns); } @ExposedGet(name = "repr") @@ -209,6 +231,9 @@ sb.append("decorator_list="); sb.append(dumpThis(decorator_list)); sb.append(","); + sb.append("returns="); + sb.append(dumpThis(returns)); + sb.append(","); sb.append(")"); return sb.toString(); } @@ -232,6 +257,8 @@ t.accept(visitor); } } + if (returns != null) + returns.accept(visitor); } private int lineno = -1; Added: branches/jy3k/src/org/python/antlr/ast/Nonlocal.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/Nonlocal.java (rev 0) +++ branches/jy3k/src/org/python/antlr/ast/Nonlocal.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -0,0 +1,147 @@ +// Autogenerated AST node +package org.python.antlr.ast; +import org.antlr.runtime.CommonToken; +import org.antlr.runtime.Token; +import org.python.antlr.AST; +import org.python.antlr.PythonTree; +import org.python.antlr.adapter.AstAdapters; +import org.python.antlr.base.excepthandler; +import org.python.antlr.base.expr; +import org.python.antlr.base.mod; +import org.python.antlr.base.slice; +import org.python.antlr.base.stmt; +import org.python.core.ArgParser; +import org.python.core.AstList; +import org.python.core.Py; +import org.python.core.PyObject; +import org.python.core.PyString; +import org.python.core.PyType; +import org.python.expose.ExposedGet; +import org.python.expose.ExposedMethod; +import org.python.expose.ExposedNew; +import org.python.expose.ExposedSet; +import org.python.expose.ExposedType; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; + +@ExposedType(name = "_ast.Nonlocal", base = AST.class) +public class Nonlocal extends stmt { +public static final PyType TYPE = PyType.fromClass(Nonlocal.class); + private java.util.List<String> names; + public java.util.List<String> getInternalNames() { + return names; + } + @ExposedGet(name = "names") + public PyObject getNames() { + return new AstList(names, AstAdapters.identifierAdapter); + } + @ExposedSet(name = "names") + public void setNames(PyObject names) { + this.names = AstAdapters.py2identifierList(names); + } + + + private final static PyString[] fields = + new PyString[] {new PyString("names")}; + @ExposedGet(name = "_fields") + public PyString[] get_fields() { return fields; } + + private final static PyString[] attributes = + new PyString[] {new PyString("lineno"), new PyString("col_offset")}; + @ExposedGet(name = "_attributes") + public PyString[] get_attributes() { return attributes; } + + public Nonlocal(PyType subType) { + super(subType); + } + public Nonlocal() { + this(TYPE); + } + @ExposedNew + @ExposedMethod + public void Nonlocal___init__(PyObject[] args, String[] keywords) { + ArgParser ap = new ArgParser("Nonlocal", args, keywords, new String[] + {"names", "lineno", "col_offset"}, 1); + setNames(ap.getPyObject(0)); + int lin = ap.getInt(1, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(2, -1); + if (col != -1) { + setLineno(col); + } + + } + + public Nonlocal(PyObject names) { + setNames(names); + } + + public Nonlocal(Token token, java.util.List<String> names) { + super(token); + this.names = names; + } + + public Nonlocal(Integer ttype, Token token, java.util.List<String> names) { + super(ttype, token); + this.names = names; + } + + public Nonlocal(PythonTree tree, java.util.List<String> names) { + super(tree); + this.names = names; + } + + @ExposedGet(name = "repr") + public String toString() { + return "Nonlocal"; + } + + public String toStringTree() { + StringBuffer sb = new StringBuffer("Nonlocal("); + sb.append("names="); + sb.append(dumpThis(names)); + sb.append(","); + sb.append(")"); + return sb.toString(); + } + + public <R> R accept(VisitorIF<R> visitor) throws Exception { + return visitor.visitNonlocal(this); + } + + public void traverse(VisitorIF visitor) throws Exception { + } + + private int lineno = -1; + @ExposedGet(name = "lineno") + public int getLineno() { + if (lineno != -1) { + return lineno; + } + return getLine(); + } + + @ExposedSet(name = "lineno") + public void setLineno(int num) { + lineno = num; + } + + private int col_offset = -1; + @ExposedGet(name = "col_offset") + public int getCol_offset() { + if (col_offset != -1) { + return col_offset; + } + return getCharPositionInLine(); + } + + @ExposedSet(name = "col_offset") + public void setCol_offset(int num) { + col_offset = num; + } + +} Deleted: branches/jy3k/src/org/python/antlr/ast/Print.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/Print.java 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/src/org/python/antlr/ast/Print.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -1,219 +0,0 @@ -// Autogenerated AST node -package org.python.antlr.ast; -import org.antlr.runtime.CommonToken; -import org.antlr.runtime.Token; -import org.python.antlr.AST; -import org.python.antlr.PythonTree; -import org.python.antlr.adapter.AstAdapters; -import org.python.antlr.base.excepthandler; -import org.python.antlr.base.expr; -import org.python.antlr.base.mod; -import org.python.antlr.base.slice; -import org.python.antlr.base.stmt; -import org.python.core.ArgParser; -import org.python.core.AstList; -import org.python.core.Py; -import org.python.core.PyObject; -import org.python.core.PyString; -import org.python.core.PyType; -import org.python.expose.ExposedGet; -import org.python.expose.ExposedMethod; -import org.python.expose.ExposedNew; -import org.python.expose.ExposedSet; -import org.python.expose.ExposedType; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.ArrayList; - -@ExposedType(name = "_ast.Print", base = AST.class) -public class Print extends stmt { -public static final PyType TYPE = PyType.fromClass(Print.class); - private expr dest; - public expr getInternalDest() { - return dest; - } - @ExposedGet(name = "dest") - public PyObject getDest() { - return dest; - } - @ExposedSet(name = "dest") - public void setDest(PyObject dest) { - this.dest = AstAdapters.py2expr(dest); - } - - private java.util.List<expr> values; - public java.util.List<expr> getInternalValues() { - return values; - } - @ExposedGet(name = "values") - public PyObject getValues() { - return new AstList(values, AstAdapters.exprAdapter); - } - @ExposedSet(name = "values") - public void setValues(PyObject values) { - this.values = AstAdapters.py2exprList(values); - } - - private Boolean nl; - public Boolean getInternalNl() { - return nl; - } - @ExposedGet(name = "nl") - public PyObject getNl() { - if (nl) return Py.True; - return Py.False; - } - @ExposedSet(name = "nl") - public void setNl(PyObject nl) { - this.nl = AstAdapters.py2bool(nl); - } - - - private final static PyString[] fields = - new PyString[] {new PyString("dest"), new PyString("values"), new PyString("nl")}; - @ExposedGet(name = "_fields") - public PyString[] get_fields() { return fields; } - - private final static PyString[] attributes = - new PyString[] {new PyString("lineno"), new PyString("col_offset")}; - @ExposedGet(name = "_attributes") - public PyString[] get_attributes() { return attributes; } - - public Print(PyType subType) { - super(subType); - } - public Print() { - this(TYPE); - } - @ExposedNew - @ExposedMethod - public void Print___init__(PyObject[] args, String[] keywords) { - ArgParser ap = new ArgParser("Print", args, keywords, new String[] - {"dest", "values", "nl", "lineno", "col_offset"}, 3); - setDest(ap.getPyObject(0)); - setValues(ap.getPyObject(1)); - setNl(ap.getPyObject(2)); - int lin = ap.getInt(3, -1); - if (lin != -1) { - setLineno(lin); - } - - int col = ap.getInt(4, -1); - if (col != -1) { - setLineno(col); - } - - } - - public Print(PyObject dest, PyObject values, PyObject nl) { - setDest(dest); - setValues(values); - setNl(nl); - } - - public Print(Token token, expr dest, java.util.List<expr> values, Boolean nl) { - super(token); - this.dest = dest; - addChild(dest); - this.values = values; - if (values == null) { - this.values = new ArrayList<expr>(); - } - for(PythonTree t : this.values) { - addChild(t); - } - this.nl = nl; - } - - public Print(Integer ttype, Token token, expr dest, java.util.List<expr> values, Boolean nl) { - super(ttype, token); - this.dest = dest; - addChild(dest); - this.values = values; - if (values == null) { - this.values = new ArrayList<expr>(); - } - for(PythonTree t : this.values) { - addChild(t); - } - this.nl = nl; - } - - public Print(PythonTree tree, expr dest, java.util.List<expr> values, Boolean nl) { - super(tree); - this.dest = dest; - addChild(dest); - this.values = values; - if (values == null) { - this.values = new ArrayList<expr>(); - } - for(PythonTree t : this.values) { - addChild(t); - } - this.nl = nl; - } - - @ExposedGet(name = "repr") - public String toString() { - return "Print"; - } - - public String toStringTree() { - StringBuffer sb = new StringBuffer("Print("); - sb.append("dest="); - sb.append(dumpThis(dest)); - sb.append(","); - sb.append("values="); - sb.append(dumpThis(values)); - sb.append(","); - sb.append("nl="); - sb.append(dumpThis(nl)); - sb.append(","); - sb.append(")"); - return sb.toString(); - } - - public <R> R accept(VisitorIF<R> visitor) throws Exception { - return visitor.visitPrint(this); - } - - public void traverse(VisitorIF visitor) throws Exception { - if (dest != null) - dest.accept(visitor); - if (values != null) { - for (PythonTree t : values) { - if (t != null) - t.accept(visitor); - } - } - } - - private int lineno = -1; - @ExposedGet(name = "lineno") - public int getLineno() { - if (lineno != -1) { - return lineno; - } - return getLine(); - } - - @ExposedSet(name = "lineno") - public void setLineno(int num) { - lineno = num; - } - - private int col_offset = -1; - @ExposedGet(name = "col_offset") - public int getCol_offset() { - if (col_offset != -1) { - return col_offset; - } - return getCharPositionInLine(); - } - - @ExposedSet(name = "col_offset") - public void setCol_offset(int num) { - col_offset = num; - } - -} Modified: branches/jy3k/src/org/python/antlr/ast/Raise.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/Raise.java 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/src/org/python/antlr/ast/Raise.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -28,48 +28,35 @@ @ExposedType(name = "_ast.Raise", base = AST.class) public class Raise extends stmt { public static final PyType TYPE = PyType.fromClass(Raise.class); - private expr excepttype; - public expr getInternalExcepttype() { - return excepttype; + private expr exc; + public expr getInternalExc() { + return exc; } - @ExposedGet(name = "excepttype") - public PyObject getExcepttype() { - return excepttype; + @ExposedGet(name = "exc") + public PyObject getExc() { + return exc; } - @ExposedSet(name = "excepttype") - public void setExcepttype(PyObject excepttype) { - this.excepttype = AstAdapters.py2expr(excepttype); + @ExposedSet(name = "exc") + public void setExc(PyObject exc) { + this.exc = AstAdapters.py2expr(exc); } - private expr inst; - public expr getInternalInst() { - return inst; + private expr cause; + public expr getInternalCause() { + return cause; } - @ExposedGet(name = "inst") - public PyObject getInst() { - return inst; + @ExposedGet(name = "cause") + public PyObject getCause() { + return cause; } - @ExposedSet(name = "inst") - public void setInst(PyObject inst) { - this.inst = AstAdapters.py2expr(inst); + @ExposedSet(name = "cause") + public void setCause(PyObject cause) { + this.cause = AstAdapters.py2expr(cause); } - private expr tback; - public expr getInternalTback() { - return tback; - } - @ExposedGet(name = "tback") - public PyObject getTback() { - return tback; - } - @ExposedSet(name = "tback") - public void setTback(PyObject tback) { - this.tback = AstAdapters.py2expr(tback); - } - private final static PyString[] fields = - new PyString[] {new PyString("excepttype"), new PyString("inst"), new PyString("tback")}; + new PyString[] {new PyString("exc"), new PyString("cause")}; @ExposedGet(name = "_fields") public PyString[] get_fields() { return fields; } @@ -88,56 +75,48 @@ @ExposedMethod public void Raise___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Raise", args, keywords, new String[] - {"excepttype", "inst", "tback", "lineno", "col_offset"}, 3); - setExcepttype(ap.getPyObject(0)); - setInst(ap.getPyObject(1)); - setTback(ap.getPyObject(2)); - int lin = ap.getInt(3, -1); + {"exc", "cause", "lineno", "col_offset"}, 2); + setExc(ap.getPyObject(0)); + setCause(ap.getPyObject(1)); + int lin = ap.getInt(2, -1); if (lin != -1) { setLineno(lin); } - int col = ap.getInt(4, -1); + int col = ap.getInt(3, -1); if (col != -1) { setLineno(col); } } - public Raise(PyObject excepttype, PyObject inst, PyObject tback) { - setExcepttype(excepttype); - setInst(inst); - setTback(tback); + public Raise(PyObject exc, PyObject cause) { + setExc(exc); + setCause(cause); } - public Raise(Token token, expr excepttype, expr inst, expr tback) { + public Raise(Token token, expr exc, expr cause) { super(token); - this.excepttype = excepttype; - addChild(excepttype); - this.inst = inst; - addChild(inst); - this.tback = tback; - addChild(tback); + this.exc = exc; + addChild(exc); + this.cause = cause; + addChild(cause); } - public Rais... [truncated message content] |
From: <cg...@us...> - 2009-01-05 07:12:46
|
Revision: 5847 http://jython.svn.sourceforge.net/jython/?rev=5847&view=rev Author: cgroves Date: 2009-01-05 07:12:43 +0000 (Mon, 05 Jan 2009) Log Message: ----------- test302 - Move to test_pep263_jy This adds a check for the encoding declared by the source file actually matching up with what we were getting out of it, and switches the default encoding to ascii to follow CPython. CPython assumes utf-8 in some single compilation contexts, and this uses the same parser algorithm everywhere, so I made a small change to test_doctest since Jython is throwing a SyntaxError on utf-8 strings to a single compilation. Modified Paths: -------------- trunk/jython/Lib/test/test_doctest.py trunk/jython/src/org/python/core/ParserFacade.java Added Paths: ----------- trunk/jython/Lib/test/invalid_utf_8_declared_encoding.py trunk/jython/Lib/test/latin1_no_encoding.py trunk/jython/Lib/test/test_pep263_jy.py Removed Paths: ------------- trunk/jython/bugtests/test302.py Added: trunk/jython/Lib/test/invalid_utf_8_declared_encoding.py =================================================================== (Binary files differ) Property changes on: trunk/jython/Lib/test/invalid_utf_8_declared_encoding.py ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/jython/Lib/test/latin1_no_encoding.py =================================================================== (Binary files differ) Property changes on: trunk/jython/Lib/test/latin1_no_encoding.py ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/jython/Lib/test/test_doctest.py =================================================================== --- trunk/jython/Lib/test/test_doctest.py 2009-01-05 07:08:51 UTC (rev 5846) +++ trunk/jython/Lib/test/test_doctest.py 2009-01-05 07:12:43 UTC (rev 5847) @@ -2265,17 +2265,18 @@ File "...", line 7, in test_doctest4.txt Failed example: u'...' - Expected: - u'f\xf6\xf6' - Got: - u'f\xc3\xb6\xc3\xb6' + ... ********************************************************************** ... ********************************************************************** + ... + ********************************************************************** + ... + ********************************************************************** 1 items had failures: - 2 of 4 in test_doctest4.txt - ***Test Failed*** 2 failures. - (2, 4) + 4 of 4 in test_doctest4.txt + ***Test Failed*** 4 failures. + (4, 4) >>> doctest.master = None # Reset master. >>> doctest.testfile('test_doctest4.txt', encoding='utf-8') Added: trunk/jython/Lib/test/test_pep263_jy.py =================================================================== --- trunk/jython/Lib/test/test_pep263_jy.py (rev 0) +++ trunk/jython/Lib/test/test_pep263_jy.py 2009-01-05 07:12:43 UTC (rev 5847) @@ -0,0 +1,16 @@ +import unittest +from test import test_support + +class BadEncodingTest(unittest.TestCase): + + def test_invalid_default(self): + self.assertRaises(SyntaxError, __import__, "test.latin1_no_encoding") + + def test_invalid_declared_encoding(self): + self.assertRaises(SyntaxError, __import__, "test.invalid_utf_8_declared_encoding") + +def test_main(): + test_support.run_unittest(BadEncodingTest) + +if __name__=="__main__": + test_main() Deleted: trunk/jython/bugtests/test302.py =================================================================== --- trunk/jython/bugtests/test302.py 2009-01-05 07:08:51 UTC (rev 5846) +++ trunk/jython/bugtests/test302.py 2009-01-05 07:12:43 UTC (rev 5847) @@ -1,20 +0,0 @@ -""" -In bug #439688 the value 0x99 does not survive the JavaCC parser. -""" - -import sys -print sys.defaultencoding -f = open("test302s.py", "wb") -f.write('v = "\x99"\n') -f.close() - -import test302s - -f = open("test302.out", "w") -f.write("\x99") -f.close(); - -from java.io import FileInputStream, InputStreamReader -readval = InputStreamReader(FileInputStream("test302.out"), 'ISO-8859-1').read() - -print ord(test302s.v) == readval Modified: trunk/jython/src/org/python/core/ParserFacade.java =================================================================== --- trunk/jython/src/org/python/core/ParserFacade.java 2009-01-05 07:08:51 UTC (rev 5846) +++ trunk/jython/src/org/python/core/ParserFacade.java 2009-01-05 07:12:43 UTC (rev 5847) @@ -8,7 +8,11 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; -import java.io.UnsupportedEncodingException; +import java.nio.charset.CharacterCodingException; +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CodingErrorAction; +import java.nio.charset.UnsupportedCharsetException; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -56,9 +60,9 @@ } // if reader != null, reset it - public static PyException fixParseError(BufferedReader reader, Throwable t, - String filename) - { + public static PyException fixParseError(ExpectedEncodingBufferedReader reader, + Throwable t, + String filename) { if (reader != null) { try { reader.reset(); @@ -82,6 +86,16 @@ return new PyIndentationError(msg, line, col, text, filename); } return new PySyntaxError(msg, line, col, text, filename); + } else if (t instanceof CharacterCodingException) { + String msg; + if (reader.encoding == null) { + msg = "Non-ASCII character in file '" + filename + "', but no encoding declared" + + "; see http://www.python.org/peps/pep-0263.html for details"; + } else { + msg = "Illegal character in file '" + filename + "' for encoding '" + + reader.encoding + "'"; + } + throw Py.SyntaxError(msg); } else return Py.JavaError(t); } @@ -93,7 +107,7 @@ * from it, to translate ParserExceptions into PySyntaxErrors or * PyIndentationErrors. */ - private static mod parse(BufferedReader reader, + private static mod parse(ExpectedEncodingBufferedReader reader, String kind, String filename, CompilerFlags cflags) throws Throwable { @@ -120,7 +134,7 @@ String kind, String filename, CompilerFlags cflags) { - BufferedReader bufReader = null; + ExpectedEncodingBufferedReader bufReader = null; try { // prepBufReader takes care of encoding detection and universal // newlines: @@ -137,7 +151,7 @@ String kind, String filename, CompilerFlags cflags) { - BufferedReader bufReader = null; + ExpectedEncodingBufferedReader bufReader = null; try { bufReader = prepBufReader(string, cflags, filename); return parse(bufReader, kind, filename, cflags); @@ -154,7 +168,7 @@ CompilerFlags cflags, boolean stdprompt) { // XXX: What's the idea of the stdprompt argument? - BufferedReader reader = null; + ExpectedEncodingBufferedReader reader = null; try { reader = prepBufReader(string, cflags, filename); return parse(reader, kind, filename, cflags); @@ -194,7 +208,21 @@ return true; } - private static BufferedReader prepBufReader(InputStream input, CompilerFlags cflags, + private static class ExpectedEncodingBufferedReader extends BufferedReader { + + /** + * The encoding from the source file, or null if none was specified and ascii is being used. + */ + public final String encoding; + + public ExpectedEncodingBufferedReader(Reader in, String encoding) { + super(in); + this.encoding = encoding; + } + } + + private static ExpectedEncodingBufferedReader prepBufReader(InputStream input, + CompilerFlags cflags, String filename) throws IOException { input = new BufferedInputStream(input); boolean bom = adjustForBOM(input); @@ -222,17 +250,19 @@ UniversalIOWrapper textIO = new UniversalIOWrapper(bufferedIO); input = new TextIOInputStream(textIO); - Reader reader; + CharsetDecoder dec; try { - // Using iso-8859-1 for the raw bytes when no encoding was specified - reader = new InputStreamReader(input, encoding == null ? "iso-8859-1" : encoding); - } catch (UnsupportedEncodingException exc) { + // Use ascii for the raw bytes when no encoding was specified + dec = Charset.forName(encoding == null ? "ascii" : encoding).newDecoder(); + } catch (UnsupportedCharsetException exc) { throw new PySyntaxError("Unknown encoding: " + encoding, 1, 0, "", filename); } - return new BufferedReader(reader); + dec.onMalformedInput(CodingErrorAction.REPORT); + dec.onUnmappableCharacter(CodingErrorAction.REPORT); + return new ExpectedEncodingBufferedReader(new InputStreamReader(input, dec), encoding); } - private static BufferedReader prepBufReader(String string, CompilerFlags cflags, + private static ExpectedEncodingBufferedReader prepBufReader(String string, CompilerFlags cflags, String filename) throws IOException { if (cflags.source_is_utf8) { // Passed unicode, re-encode the String to raw bytes @@ -246,7 +276,7 @@ } /** - * Check for a BOM mark at the begginning of stream. If there is a BOM + * Check for a BOM mark at the beginning of stream. If there is a BOM * mark, advance the stream passed it. If not, reset() to start at the * beginning of the stream again. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |