You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(107) |
Dec
(67) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(76) |
Feb
(125) |
Mar
(72) |
Apr
(13) |
May
(18) |
Jun
(12) |
Jul
(129) |
Aug
(47) |
Sep
(1) |
Oct
(36) |
Nov
(128) |
Dec
(124) |
2002 |
Jan
(59) |
Feb
|
Mar
(14) |
Apr
(14) |
May
(72) |
Jun
(9) |
Jul
(3) |
Aug
(5) |
Sep
(18) |
Oct
(65) |
Nov
(28) |
Dec
(12) |
2003 |
Jan
(10) |
Feb
(2) |
Mar
(4) |
Apr
(33) |
May
(21) |
Jun
(9) |
Jul
(29) |
Aug
(34) |
Sep
(4) |
Oct
(8) |
Nov
(15) |
Dec
(4) |
2004 |
Jan
(26) |
Feb
(12) |
Mar
(11) |
Apr
(9) |
May
(7) |
Jun
|
Jul
(5) |
Aug
|
Sep
(3) |
Oct
(7) |
Nov
(1) |
Dec
(10) |
2005 |
Jan
(2) |
Feb
(72) |
Mar
(16) |
Apr
(39) |
May
(48) |
Jun
(97) |
Jul
(57) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(100) |
Dec
(24) |
2006 |
Jan
(15) |
Feb
(34) |
Mar
(33) |
Apr
(31) |
May
(79) |
Jun
(64) |
Jul
(41) |
Aug
(64) |
Sep
(31) |
Oct
(46) |
Nov
(55) |
Dec
(37) |
2007 |
Jan
(32) |
Feb
(61) |
Mar
(11) |
Apr
(58) |
May
(46) |
Jun
(30) |
Jul
(94) |
Aug
(93) |
Sep
(86) |
Oct
(69) |
Nov
(125) |
Dec
(177) |
2008 |
Jan
(169) |
Feb
(97) |
Mar
(74) |
Apr
(113) |
May
(120) |
Jun
(334) |
Jul
(215) |
Aug
(237) |
Sep
(72) |
Oct
(189) |
Nov
(126) |
Dec
(160) |
2009 |
Jan
(180) |
Feb
(45) |
Mar
(98) |
Apr
(140) |
May
(151) |
Jun
(71) |
Jul
(107) |
Aug
(119) |
Sep
(73) |
Oct
(121) |
Nov
(14) |
Dec
(6) |
2010 |
Jan
(13) |
Feb
(9) |
Mar
(10) |
Apr
(64) |
May
(3) |
Jun
(16) |
Jul
(7) |
Aug
(23) |
Sep
(17) |
Oct
(37) |
Nov
(5) |
Dec
(8) |
2011 |
Jan
(10) |
Feb
(11) |
Mar
(77) |
Apr
(11) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <fwi...@us...> - 2008-09-11 20:18:46
|
Revision: 5321 http://jython.svn.sourceforge.net/jython/?rev=5321&view=rev Author: fwierzbicki Date: 2008-09-11 20:18:43 +0000 (Thu, 11 Sep 2008) Log Message: ----------- Allow the possibility of using error nodes for bad stmtType. 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 2008-09-11 19:48:35 UTC (rev 5320) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2008-09-11 20:18:43 UTC (rev 5321) @@ -191,6 +191,17 @@ return new stmtType[]{(stmtType)elif}; } + stmtType makeStmt(Object o) { + if (o instanceof stmtType) { + return (stmtType)o; + } else if (o instanceof PythonParser.stmt_return) { + return (stmtType)((PythonParser.stmt_return)o).tree; + } else if (o instanceof PythonTree) { + return errorHandler.errorStmt((PythonTree)o); + } + return null; + } + stmtType[] makeStmts(PythonTree t) { return new stmtType[]{(stmtType)t}; } @@ -198,18 +209,8 @@ stmtType[] makeStmts(List stmts) { if (stmts != null) { List<stmtType> result = new ArrayList<stmtType>(); - for (int i=0; i<stmts.size(); i++) { - Object o = stmts.get(i); - if (o instanceof stmtType) { - result.add((stmtType)o); - } else if (o instanceof PythonTree) { - PythonTree t = (PythonTree)o; - for (int j=0; j<t.getChildCount(); j++) { - result.add((stmtType)t.getChild(i)); - } - } else { - result.add((stmtType)((PythonParser.stmt_return)o).tree); - } + for (Object o:stmts) { + result.add(makeStmt(o)); } return (stmtType[])result.toArray(new stmtType[result.size()]); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-11 19:48:37
|
Revision: 5320 http://jython.svn.sourceforge.net/jython/?rev=5320&view=rev Author: fwierzbicki Date: 2008-09-11 19:48:35 +0000 (Thu, 11 Sep 2008) Log Message: ----------- Transform if/elif/else into the correct If nodes in the grammar file instead of as a code post-processing step. Modified Paths: -------------- trunk/jython/grammar/Python.g trunk/jython/src/org/python/antlr/GrammarActions.java Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2008-09-11 01:33:39 UTC (rev 5319) +++ trunk/jython/grammar/Python.g 2008-09-11 19:48:35 UTC (rev 5320) @@ -797,18 +797,31 @@ //if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] if_stmt - : IF test[expr_contextType.Load] COLON ifsuite=suite elifs+=elif_clause* - (ORELSE COLON elsesuite=suite)? + : IF test[expr_contextType.Load] COLON ifsuite=suite elif_clause[$test.start]? -> ^(IF<If>[$IF, actions.makeExpr($test.tree), actions.makeStmts($ifsuite.stypes), - actions.makeElses($elsesuite.stypes, $elifs)]) + actions.makeElse($elif_clause.stypes, $elif_clause.tree)]) ; //not in CPython's Grammar file -elif_clause - : ELIF test[expr_contextType.Load] COLON suite - -> ^(ELIF<If>[$test.start, actions.makeExpr($test.tree), actions.makeStmts($suite.stypes), new stmtType[0\]]) +elif_clause [Token iftest] returns [List stypes] + : else_clause { + $stypes = $else_clause.stypes; + } + | ELIF test[expr_contextType.Load] COLON suite + (e2=elif_clause[$iftest] + -> ^(ELIF<If>[$iftest, actions.makeExpr($test.tree), actions.makeStmts($suite.stypes), actions.makeElse($e2.stypes, $e2.tree)]) + | + -> ^(ELIF<If>[$iftest, actions.makeExpr($test.tree), actions.makeStmts($suite.stypes), new stmtType[0\]]) + ) ; +//not in CPython's Grammar file +else_clause returns [List stypes] + : ORELSE COLON elsesuite=suite { + $stypes = $suite.stypes; + } + ; + //while_stmt: 'while' test ':' suite ['else' ':' suite] while_stmt @init { Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2008-09-11 01:33:39 UTC (rev 5319) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2008-09-11 19:48:35 UTC (rev 5320) @@ -182,18 +182,13 @@ return new exprType[0]; } - stmtType[] makeElses(List elseSuite, List elifs) { - stmtType[] o; - o = makeStmts(elseSuite); - if (elifs != null) { - ListIterator iter = elifs.listIterator(elifs.size()); - while (iter.hasPrevious()) { - If elif = (If)iter.previous(); - elif.orelse = o; - o = new stmtType[]{elif}; - } + stmtType[] makeElse(List elseSuite, PythonTree elif) { + if (elseSuite != null) { + return makeStmts(elseSuite); + } else if (elif == null) { + return new stmtType[0]; } - return o; + return new stmtType[]{(stmtType)elif}; } stmtType[] makeStmts(PythonTree t) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-11 01:33:42
|
Revision: 5319 http://jython.svn.sourceforge.net/jython/?rev=5319&view=rev Author: fwierzbicki Date: 2008-09-11 01:33:39 +0000 (Thu, 11 Sep 2008) Log Message: ----------- New better version of alpha3. Added Paths: ----------- tags/Release_2_5alpha3/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-11 01:33:09
|
Revision: 5318 http://jython.svn.sourceforge.net/jython/?rev=5318&view=rev Author: fwierzbicki Date: 2008-09-11 01:33:08 +0000 (Thu, 11 Sep 2008) Log Message: ----------- removing this tag since it was broken. Removed Paths: ------------- tags/Release_2_5alpha3/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-11 00:39:46
|
Revision: 5317 http://jython.svn.sourceforge.net/jython/?rev=5317&view=rev Author: fwierzbicki Date: 2008-09-11 00:39:43 +0000 (Thu, 11 Sep 2008) Log Message: ----------- Change defaults for alpha 3. Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2008-09-11 00:37:30 UTC (rev 5316) +++ trunk/jython/build.xml 2008-09-11 00:39:43 UTC (rev 5317) @@ -183,11 +183,11 @@ <property name="PY_RELEASE_LEVEL_SNAPSHOT" value="170"/> <!-- 0xAA --> <!-- The current version info --> - <property name="jython.version" value="2.5a2+"/> - <property name="jython.version.noplus" value="2.5a2"/> + <property name="jython.version" value="2.5a3+"/> + <property name="jython.version.noplus" value="2.5a3"/> <property name="jython.major_version" value="2"/> <property name="jython.minor_version" value="5"/> - <property name="jython.micro_version" value="1"/> + <property name="jython.micro_version" value="3"/> <property name="jython.release_level" value="${PY_RELEASE_LEVEL_ALPHA}"/> <property name="jython.release_serial" value="0"/> @@ -389,7 +389,7 @@ <target name="brand-readme-version" depends="checkout" if="do.snapshot.build"> <!-- change README.txt version string, if so defined: used for snapshot builds. XXX: a bit broken for now--> - <replace file="${jython.base.dir}/README.txt" token='2.5a2+' + <replace file="${jython.base.dir}/README.txt" token='2.5a3+' value='2.5a${svn.revision}' /> <replace file="${jython.base.dir}/README.txt"> <replacetoken>=======================</replacetoken> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-11 00:37:33
|
Revision: 5316 http://jython.svn.sourceforge.net/jython/?rev=5316&view=rev Author: fwierzbicki Date: 2008-09-11 00:37:30 +0000 (Thu, 11 Sep 2008) Log Message: ----------- update readme for Jython 2.5a3. Modified Paths: -------------- trunk/jython/README.txt Modified: trunk/jython/README.txt =================================================================== --- trunk/jython/README.txt 2008-09-10 23:06:04 UTC (rev 5315) +++ trunk/jython/README.txt 2008-09-11 00:37:30 UTC (rev 5316) @@ -1,9 +1,12 @@ -Welcome to Jython 2.5a2+ +Welcome to Jython 2.5a3 ======================= -This is the second alpha of the 2.5 version of Jython. It +This is the third alpha of the 2.5 version of Jython. It contains most of the new features for the 2.5 release. +This release fixes an installation bug on windows and restores standalone +mode. + The release was compiled on Mac OS X with JDK 5 and requires JDK 5 to run. As an alpha release, this release is incomplete and contains bugs. Do not This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2008-09-10 23:06:06
|
Revision: 5315 http://jython.svn.sourceforge.net/jython/?rev=5315&view=rev Author: otmarhumbel Date: 2008-09-10 23:06:04 +0000 (Wed, 10 Sep 2008) Log Message: ----------- reintroduced the possibility to suppress checkout in full-build (setting do.checkout to 'false' does not prevent from checking out, but not setting the property at all really does) so full-build behaviour should remain the same Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2008-09-10 22:45:07 UTC (rev 5314) +++ trunk/jython/build.xml 2008-09-10 23:06:04 UTC (rev 5315) @@ -225,14 +225,12 @@ <property name="work.dir" value="${basedir}/../full_build/work" /> <property name="svn.checkout.dir" value="${work.dir}/checkout" /> <property name="jython.base.dir" value="${svn.checkout.dir}/${svn.code.dir}" /> - <property name="has.repositories.connection" value="true" /> <property name="python.exe" value="${python.home}/python" /> - <property name="do.checkout" value="false" /> - <!-- + <!-- set has.repositories.connection to false in ant.properties if you want to skip checkout --> + <property name="has.repositories.connection" value="true" /> <condition property="do.checkout" value="true"> <istrue value="${has.repositories.connection}" /> </condition> - --> <!-- classpath for svn ant task --> <path id="svn.classpath"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2008-09-10 22:45:09
|
Revision: 5314 http://jython.svn.sourceforge.net/jython/?rev=5314&view=rev Author: otmarhumbel Date: 2008-09-10 22:45:07 +0000 (Wed, 10 Sep 2008) Log Message: ----------- since property cpythonlib.present is always true if jython is checked out correctly, but is evaluated too early (long before checkout) during a full-build, it has probably no usage any more Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2008-09-10 18:36:16 UTC (rev 5313) +++ trunk/jython/build.xml 2008-09-10 22:45:07 UTC (rev 5314) @@ -162,7 +162,6 @@ <available property="informix.present" classname="com.informix.jdbc.IfxDriver" classpath="${informix.jar}" /> <available property="oracle.present" classname="oracle.jdbc.driver.OracleDriver" classpath="${oracle.jar}" /> - <available property="cpythonlib.present" file="${jython.base.dir}/CPythonLib.includes"/> <path id="test.classpath"> <path refid="main.classpath"/> @@ -667,7 +666,7 @@ </target> - <target name="copy-cpythonlib" if="cpythonlib.present"> + <target name="copy-cpythonlib"> <copy todir="${dist.dir}/Lib"> <fileset dir="${python.lib}" excludes="**/*.pyc, **/*.pyo" includesfile="${jython.base.dir}/CPythonLib.includes"> <!-- The include file gets all of CPythonLib's test directory, but we only want the ones from Jython's Lib. --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-10 18:36:19
|
Revision: 5313 http://jython.svn.sourceforge.net/jython/?rev=5313&view=rev Author: fwierzbicki Date: 2008-09-10 18:36:16 +0000 (Wed, 10 Sep 2008) Log Message: ----------- Make it possible to get error nodes into the spots that are now casting to exprType. Modified Paths: -------------- trunk/jython/grammar/Python.g trunk/jython/src/org/python/antlr/GrammarActions.java Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2008-09-10 13:05:27 UTC (rev 5312) +++ trunk/jython/grammar/Python.g 2008-09-10 18:36:16 UTC (rev 5313) @@ -312,7 +312,7 @@ $eval_input.tree = mtype; } : LEADING_WS? (NEWLINE)* testlist[expr_contextType.Load] (NEWLINE)* EOF { - mtype = new Expression($eval_input.start, (exprType)$testlist.tree); + mtype = new Expression($eval_input.start, actions.makeExpr($testlist.tree)); } ; @@ -424,7 +424,7 @@ } : fpdef[expr_contextType.Param] (ASSIGN test[expr_contextType.Load])? { - $etype = (exprType)$fpdef.tree; + $etype = actions.makeExpr($fpdef.tree); if ($ASSIGN != null) { defaults.add($test.tree); } else if (!defaults.isEmpty()) { @@ -462,7 +462,7 @@ //fpdef: NAME | '(' fplist ')' fpdef[expr_contextType ctype] @after { - actions.checkAssign((exprType)$fpdef.tree); + actions.checkAssign(actions.makeExpr($fpdef.tree)); } : NAME -> ^(NAME<Name>[$NAME, $NAME.text, ctype]) @@ -529,31 +529,31 @@ : ((testlist[null] augassign) => lhs=testlist[expr_contextType.AugStore] ( (aay=augassign y1=yield_expr { - actions.checkAssign((exprType)$lhs.tree); - stype = new AugAssign($lhs.tree, (exprType)$lhs.tree, $aay.op, (exprType)$y1.tree); + actions.checkAssign(actions.makeExpr($lhs.tree)); + stype = new AugAssign($lhs.tree, actions.makeExpr($lhs.tree), $aay.op, actions.makeExpr($y1.tree)); } ) | (aat=augassign rhs=testlist[expr_contextType.Load] { - actions.checkAssign((exprType)$lhs.tree); - stype = new AugAssign($lhs.tree, (exprType)$lhs.tree, $aat.op, (exprType)$rhs.tree); + actions.checkAssign(actions.makeExpr($lhs.tree)); + stype = new AugAssign($lhs.tree, actions.makeExpr($lhs.tree), $aat.op, actions.makeExpr($rhs.tree)); } ) ) | (testlist[null] ASSIGN) => lhs=testlist[expr_contextType.Store] ( | ((at=ASSIGN t+=testlist[expr_contextType.Store])+ - -> ^(ASSIGN<Assign>[$lhs.start, actions.makeAssignTargets((exprType)$lhs.tree, $t), + -> ^(ASSIGN<Assign>[$lhs.start, actions.makeAssignTargets(actions.makeExpr($lhs.tree), $t), actions.makeAssignValue($t)]) ) | ((ay=ASSIGN y2+=yield_expr)+ - -> ^(ASSIGN<Assign>[$lhs.start, actions.makeAssignTargets((exprType)$lhs.tree, $y2), + -> ^(ASSIGN<Assign>[$lhs.start, actions.makeAssignTargets(actions.makeExpr($lhs.tree), $y2), actions.makeAssignValue($y2)]) ) ) | lhs=testlist[expr_contextType.Load] { - stype = new Expr($lhs.start, (exprType)$lhs.tree); + stype = new Expr($lhs.start, actions.makeExpr($lhs.tree)); } ) ; @@ -582,7 +582,7 @@ (t1=printlist -> ^(PRINT<Print>[$PRINT, null, actions.makeExprs($t1.elts), $t1.newline]) | RIGHTSHIFT t2=printlist2 - -> ^(PRINT<Print>[$PRINT, (exprType)$t2.elts.get(0), actions.makeExprs($t2.elts, 1), $t2.newline]) + -> ^(PRINT<Print>[$PRINT, actions.makeExpr($t2.elts.get(0)), actions.makeExprs($t2.elts, 1), $t2.newline]) | -> ^(PRINT<Print>[$PRINT, null, new exprType[0\], false]) ) @@ -666,7 +666,7 @@ return_stmt : RETURN (testlist[expr_contextType.Load] - -> ^(RETURN<Return>[$RETURN, (exprType)$testlist.tree]) + -> ^(RETURN<Return>[$RETURN, actions.makeExpr($testlist.tree)]) | -> ^(RETURN<Return>[$RETURN, null]) ) @@ -674,14 +674,14 @@ //yield_stmt: yield_expr yield_stmt - : yield_expr -> ^(YIELD<Expr>[$yield_expr.start, (exprType)$yield_expr.tree]) + : yield_expr -> ^(YIELD<Expr>[$yield_expr.start, actions.makeExpr($yield_expr.tree)]) ; //raise_stmt: 'raise' [test [',' test [',' test]]] raise_stmt : RAISE (t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load] (COMMA t3=test[expr_contextType.Load])?)?)? - -> ^(RAISE<Raise>[$RAISE, (exprType)$t1.tree, (exprType)$t2.tree, (exprType)$t3.tree]) + -> ^(RAISE<Raise>[$RAISE, actions.makeExpr($t1.tree), actions.makeExpr($t2.tree), actions.makeExpr($t3.tree)]) ; //import_stmt: import_name | import_from @@ -774,14 +774,14 @@ : EXEC expr[expr_contextType.Load] (IN t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])?)? { - stype = new Exec($EXEC, (exprType)$expr.tree, (exprType)$t1.tree, (exprType)$t2.tree); + stype = new Exec($EXEC, actions.makeExpr($expr.tree), actions.makeExpr($t1.tree), actions.makeExpr($t2.tree)); } ; //assert_stmt: 'assert' test [',' test] assert_stmt : ASSERT t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])? - -> ^(ASSERT<Assert>[$ASSERT, (exprType)$t1.tree, (exprType)$t2.tree]) + -> ^(ASSERT<Assert>[$ASSERT, actions.makeExpr($t1.tree), actions.makeExpr($t2.tree)]) ; //compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef @@ -799,14 +799,14 @@ if_stmt : IF test[expr_contextType.Load] COLON ifsuite=suite elifs+=elif_clause* (ORELSE COLON elsesuite=suite)? - -> ^(IF<If>[$IF, (exprType)$test.tree, actions.makeStmts($ifsuite.stypes), + -> ^(IF<If>[$IF, actions.makeExpr($test.tree), actions.makeStmts($ifsuite.stypes), actions.makeElses($elsesuite.stypes, $elifs)]) ; //not in CPython's Grammar file elif_clause : ELIF test[expr_contextType.Load] COLON suite - -> ^(ELIF<If>[$test.start, (exprType)$test.tree, actions.makeStmts($suite.stypes), new stmtType[0\]]) + -> ^(ELIF<If>[$test.start, actions.makeExpr($test.tree), actions.makeStmts($suite.stypes), new stmtType[0\]]) ; //while_stmt: 'while' test ':' suite ['else' ':' suite] @@ -819,7 +819,7 @@ } : WHILE test[expr_contextType.Load] COLON s1=suite (ORELSE COLON s2=suite)? { - stype = actions.makeWhile($WHILE, (exprType)$test.tree, $s1.stypes, $s2.stypes); + stype = actions.makeWhile($WHILE, actions.makeExpr($test.tree), $s1.stypes, $s2.stypes); } ; @@ -834,7 +834,7 @@ : FOR exprlist[expr_contextType.Store] IN testlist[expr_contextType.Load] COLON s1=suite (ORELSE COLON s2=suite)? { - stype = actions.makeFor($FOR, $exprlist.etype, (exprType)$testlist.tree, $s1.stypes, $s2.stypes); + stype = actions.makeFor($FOR, $exprlist.etype, actions.makeExpr($testlist.tree), $s1.stypes, $s2.stypes); } ; @@ -872,7 +872,7 @@ } : WITH test[expr_contextType.Load] (with_var)? COLON suite { - stype = new With($WITH, (exprType)$test.tree, $with_var.etype, + stype = new With($WITH, actions.makeExpr($test.tree), $with_var.etype, actions.makeStmts($suite.stypes)); } ; @@ -881,14 +881,14 @@ with_var returns [exprType etype] : (AS | NAME) expr[expr_contextType.Store] { - $etype = (exprType)$expr.tree; + $etype = actions.makeExpr($expr.tree); } ; //except_clause: 'except' [test [',' test]] except_clause : EXCEPT (t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Store])?)? COLON suite - -> ^(EXCEPT<excepthandlerType>[$EXCEPT, (exprType)$t1.tree, (exprType)$t2.tree, + -> ^(EXCEPT<excepthandlerType>[$EXCEPT, actions.makeExpr($t1.tree), actions.makeExpr($t2.tree), actions.makeStmts($suite.stypes), $EXCEPT.getLine(), $EXCEPT.getCharPositionInLine()]) ; @@ -913,7 +913,7 @@ test[expr_contextType ctype] :o1=or_test[ctype] ( (IF or_test[null] ORELSE) => IF o2=or_test[ctype] ORELSE e=test[expr_contextType.Load] - -> ^(IF<IfExp>[$o1.start, (exprType)$o2.tree, (exprType)$o1.tree, (exprType)$e.tree]) + -> ^(IF<IfExp>[$o1.start, actions.makeExpr($o2.tree), actions.makeExpr($o1.tree), actions.makeExpr($e.tree)]) | -> or_test ) @@ -953,7 +953,7 @@ //not_test: 'not' not_test | comparison not_test[expr_contextType ctype] : NOT nt=not_test[ctype] - -> ^(NOT<UnaryOp>[$NOT, unaryopType.Not, (exprType)$nt.tree]) + -> ^(NOT<UnaryOp>[$NOT, unaryopType.Not, actions.makeExpr($nt.tree)]) | comparison[ctype] ; @@ -964,7 +964,7 @@ } @after { if (!cmps.isEmpty()) { - $comparison.tree = new Compare($left.start, (exprType)$left.tree, actions.makeCmpOps(cmps), + $comparison.tree = new Compare($left.start, actions.makeExpr($left.tree), actions.makeCmpOps(cmps), actions.makeExprs($right)); } } @@ -1123,7 +1123,7 @@ : PLUS p=factor {$etype = new UnaryOp($PLUS, unaryopType.UAdd, $p.etype);} | MINUS m=factor {$etype = actions.negate($MINUS, $m.etype);} | TILDE t=factor {$etype = new UnaryOp($TILDE, unaryopType.Invert, $t.etype);} - | power {$etype = (exprType)$power.tree;} + | power {$etype = actions.makeExpr($power.tree);} ; //power: atom trailer* ['**' factor] @@ -1134,7 +1134,7 @@ : atom (t+=trailer[$atom.start, $atom.tree])* (options {greedy=true;}:d=DOUBLESTAR factor)? { //XXX: This could be better. - $etype = (exprType)$atom.tree; + $etype = actions.makeExpr($atom.tree); if ($t != null) { for(Object o : $t) { if ($etype instanceof Context) { @@ -1194,7 +1194,7 @@ ) RCURLY | lb=BACKQUOTE testlist[expr_contextType.Load] rb=BACKQUOTE - -> ^(BACKQUOTE<Repr>[$lb, (exprType)$testlist.tree]) + -> ^(BACKQUOTE<Repr>[$lb, actions.makeExpr($testlist.tree)]) | NAME -> ^(NAME<Name>[$NAME, $NAME.text, $expr::ctype]) | INT @@ -1224,7 +1224,7 @@ Collections.reverse(gens); comprehensionType[] c = (comprehensionType[])gens.toArray(new comprehensionType[gens.size()]); - etype = new ListComp($listmaker.start, (exprType)$t.get(0), c); + etype = new ListComp($listmaker.start, actions.makeExpr($t.get(0)), c); } | (options {greedy=true;}:COMMA t+=test[$expr::ctype])* { @@ -1254,11 +1254,11 @@ { Collections.reverse(gens); comprehensionType[] c = (comprehensionType[])gens.toArray(new comprehensionType[gens.size()]); - exprType e = (exprType)$t.get(0); + exprType e = actions.makeExpr($t.get(0)); if (e instanceof Context) { ((Context)e).setContext(expr_contextType.Load); } - etype = new GeneratorExp($testlist_gexp.start, (exprType)$t.get(0), c); + etype = new GeneratorExp($testlist_gexp.start, actions.makeExpr($t.get(0)), c); } ) ) @@ -1278,7 +1278,7 @@ if (a == null) { a = new argumentsType($LAMBDA, new exprType[0], null, null, new exprType[0]); } - etype = new Lambda($LAMBDA, a, (exprType)$test.tree); + etype = new Lambda($LAMBDA, a, actions.makeExpr($test.tree)); } ; @@ -1286,16 +1286,16 @@ trailer [Token begin, PythonTree tree] : LPAREN (arglist - -> ^(LPAREN<Call>[$begin, (exprType)$tree, actions.makeExprs($arglist.args), + -> ^(LPAREN<Call>[$begin, actions.makeExpr($tree), actions.makeExprs($arglist.args), actions.makeKeywords($arglist.keywords), $arglist.starargs, $arglist.kwargs]) | - -> ^(LPAREN<Call>[$begin, (exprType)$tree, new exprType[0\], new keywordType[0\], null, null]) + -> ^(LPAREN<Call>[$begin, actions.makeExpr($tree), new exprType[0\], new keywordType[0\], null, null]) ) RPAREN | LBRACK subscriptlist[$begin] RBRACK - -> ^(LBRACK<Subscript>[$begin, (exprType)$tree, (sliceType)$subscriptlist.tree, $expr::ctype]) + -> ^(LBRACK<Subscript>[$begin, actions.makeExpr($tree), (sliceType)$subscriptlist.tree, $expr::ctype]) | DOT attr - -> ^(DOT<Attribute>[$begin, (exprType)$tree, $attr.text, $expr::ctype]) + -> ^(DOT<Attribute>[$begin, actions.makeExpr($tree), $attr.text, $expr::ctype]) ; //subscriptlist: subscript (',' subscript)* [','] @@ -1332,7 +1332,7 @@ $sltype = actions.makeSubscript(null, $c2, $upper2.tree, $sliceop.tree); } | test[expr_contextType.Load] - -> ^(LPAREN<Index>[$test.start, (exprType)$test.tree]) + -> ^(LPAREN<Index>[$test.start, actions.makeExpr($test.tree)]) ; //sliceop: ':' [test] @@ -1351,7 +1351,7 @@ } | expr[ctype] { - $etype = (exprType)$expr.tree; + $etype = actions.makeExpr($expr.tree); } ; @@ -1393,7 +1393,7 @@ } : CLASS NAME (LPAREN testlist[expr_contextType.Load]? RPAREN)? COLON suite { - stype = new ClassDef($CLASS, actions.cantBeNone($NAME), actions.makeBases((exprType)$testlist.tree), + stype = new ClassDef($CLASS, actions.cantBeNone($NAME), actions.makeBases(actions.makeExpr($testlist.tree)), actions.makeStmts($suite.stypes)); } ; @@ -1417,17 +1417,17 @@ } $args=arguments; $keywords=kws; - $starargs=(exprType)$s.tree; - $kwargs=(exprType)$k.tree; + $starargs=actions.makeExpr($s.tree); + $kwargs=actions.makeExpr($k.tree); } | STAR s=test[expr_contextType.Load] (COMMA DOUBLESTAR k=test[expr_contextType.Load])? { - $starargs=(exprType)$s.tree; - $kwargs=(exprType)$k.tree; + $starargs=actions.makeExpr($s.tree); + $kwargs=actions.makeExpr($k.tree); } | DOUBLESTAR k=test[expr_contextType.Load] { - $kwargs=(exprType)$k.tree; + $kwargs=actions.makeExpr($k.tree); } ; @@ -1436,7 +1436,7 @@ : t1=test[expr_contextType.Load] ((ASSIGN t2=test[expr_contextType.Load]) { - $kws.add(new exprType[]{(exprType)$t1.tree, (exprType)$t2.tree}); + $kws.add(new exprType[]{actions.makeExpr($t1.tree), actions.makeExpr($t2.tree)}); } | gen_for[$gens] { @@ -1446,7 +1446,7 @@ $genarg = true; Collections.reverse($gens); comprehensionType[] c = (comprehensionType[])$gens.toArray(new comprehensionType[$gens.size()]); - arguments.add(new GeneratorExp($t1.start, (exprType)$t1.tree, c)); + arguments.add(new GeneratorExp($t1.start, actions.makeExpr($t1.tree), c)); } | { if (kws.size() > 0) { @@ -1475,7 +1475,7 @@ } else { e = new exprType[0]; } - gens.add(new comprehensionType($FOR, $exprlist.etype, (exprType)$testlist.tree, e)); + gens.add(new comprehensionType($FOR, $exprlist.etype, actions.makeExpr($testlist.tree), e)); } ; @@ -1483,7 +1483,7 @@ list_if[List gens] returns [exprType etype] : IF test[expr_contextType.Load] (list_iter[gens])? { - $etype = (exprType)$test.tree; + $etype = actions.makeExpr($test.tree); } ; @@ -1506,7 +1506,7 @@ } else { e = new exprType[0]; } - gens.add(new comprehensionType($FOR, $exprlist.etype, (exprType)$or_test.tree, e)); + gens.add(new comprehensionType($FOR, $exprlist.etype, actions.makeExpr($or_test.tree), e)); } ; @@ -1514,14 +1514,14 @@ gen_if[List gens] returns [exprType etype] : IF test[expr_contextType.Load] gen_iter[gens]? { - $etype = (exprType)$test.tree; + $etype = actions.makeExpr($test.tree); } ; //yield_expr: 'yield' [testlist] yield_expr : YIELD testlist[expr_contextType.Load]? - -> ^(YIELD<Yield>[$YIELD, (exprType)$testlist.tree]) + -> ^(YIELD<Yield>[$YIELD, actions.makeExpr($testlist.tree)]) ; AS : 'as' ; Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2008-09-10 13:05:27 UTC (rev 5312) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2008-09-10 18:36:16 UTC (rev 5313) @@ -151,6 +151,17 @@ errorHandler.error("Generator expression must be parenthesized if not sole argument", t); } + exprType makeExpr(Object o) { + if (o instanceof exprType) { + return (exprType)o; + } + if (o instanceof PythonTree) { + return errorHandler.errorExpr((PythonTree)o); + } + return null; + } + + exprType[] makeExprs(List exprs) { return makeExprs(exprs, 0); } @@ -280,7 +291,7 @@ checkAssign(lhs); e[0] = lhs; for(int i=0;i<rhs.size() - 1;i++) { - exprType r = (exprType)rhs.get(i); + exprType r = makeExpr(rhs.get(i)); checkAssign(r); e[i + 1] = r; } @@ -288,7 +299,7 @@ } exprType makeAssignValue(List rhs) { - exprType value = (exprType)rhs.get(rhs.size() -1); + exprType value = makeExpr(rhs.get(rhs.size() -1)); recurseSetContext(value, expr_contextType.Load); return value; } @@ -654,18 +665,18 @@ exprType e = null; exprType o = null; if (lower != null) { - s = (exprType)lower; + s = makeExpr(lower); } if (colon != null) { isSlice = true; if (upper != null) { - e = (exprType)upper; + e = makeExpr(upper); } } if (sliceop != null) { isSlice = true; if (sliceop != null) { - o = (exprType)sliceop; + o = makeExpr(sliceop); } else { o = new Name(sliceop, "None", expr_contextType.Load); } @@ -702,18 +713,18 @@ } BinOp makeBinOp(PythonTree left, operatorType op, List rights) { - BinOp current = new BinOp(left, (exprType)left, op, (exprType)rights.get(0)); + BinOp current = new BinOp(left, makeExpr(left), op, makeExpr(rights.get(0))); for (int i = 1; i< rights.size(); i++) { - exprType right = (exprType)rights.get(i); + exprType right = makeExpr(rights.get(i)); current = new BinOp(left, current, op, right); } return current; } BinOp makeBinOp(PythonTree left, List ops, List rights) { - BinOp current = new BinOp(left, (exprType)left, (operatorType)ops.get(0), (exprType)rights.get(0)); + BinOp current = new BinOp(left, makeExpr(left), (operatorType)ops.get(0), makeExpr(rights.get(0))); for (int i = 1; i< rights.size(); i++) { - exprType right = (exprType)rights.get(i); + exprType right = makeExpr(rights.get(i)); operatorType op = (operatorType)ops.get(i); current = new BinOp(left, current, op, right); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-10 13:05:29
|
Revision: 5312 http://jython.svn.sourceforge.net/jython/?rev=5312&view=rev Author: fwierzbicki Date: 2008-09-10 13:05:27 +0000 (Wed, 10 Sep 2008) Log Message: ----------- Removing unused branches, including the premature Release_2_5maint (silly to create a maint branch until a prod release). Removed Paths: ------------- branches/Release_2_5maint/ branches/installer25/ branches/nowalker/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-10 04:08:58
|
Revision: 5311 http://jython.svn.sourceforge.net/jython/?rev=5311&view=rev Author: fwierzbicki Date: 2008-09-10 04:08:55 +0000 (Wed, 10 Sep 2008) Log Message: ----------- tagging a third alpha. Added Paths: ----------- tags/Release_2_5alpha3/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-10 03:59:24
|
Revision: 5310 http://jython.svn.sourceforge.net/jython/?rev=5310&view=rev Author: fwierzbicki Date: 2008-09-10 03:59:17 +0000 (Wed, 10 Sep 2008) Log Message: ----------- Merged revisions 5300-5308 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/trunk ........ r5300 | fwierzbicki | 2008-09-06 19:20:46 -0400 (Sat, 06 Sep 2008) | 2 lines Add alpha2 link and remove jeps directory. ........ r5301 | fwierzbicki | 2008-09-07 01:57:26 -0400 (Sun, 07 Sep 2008) | 2 lines Committing Nicholas Riley's patch after getting test_ast.py to work. See http://bugs.jython.org/issue1758279. ........ r5302 | otmarhumbel | 2008-09-08 10:41:41 -0400 (Mon, 08 Sep 2008) | 9 lines Fix for issue #1123: Weird "unexpected at this time" error. The tests if environment variables JAVA_HOME or JYTHON_HOME are set did not work: - if the path contained a space - if the variable really was not set The passed (manual, so far) tests can be found in: http://bugs.jython.org/msg3489 ........ r5303 | leosoto | 2008-09-08 13:48:28 -0400 (Mon, 08 Sep 2008) | 1 line SystemRandom implementation taken from CPython. It depends on urandom(), which seems supported now through jna-posix ........ r5304 | fwierzbicki | 2008-09-09 14:42:57 -0400 (Tue, 09 Sep 2008) | 2 lines Fix some offset problems in DEDENT, INDENT, and EOF. ........ r5305 | fwierzbicki | 2008-09-09 15:06:17 -0400 (Tue, 09 Sep 2008) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib@66318 ........ r5306 | otmarhumbel | 2008-09-09 16:35:30 -0400 (Tue, 09 Sep 2008) | 2 lines enable compilation for full-build (-A is still broken) ........ r5307 | fwierzbicki | 2008-09-09 17:15:54 -0400 (Tue, 09 Sep 2008) | 2 lines Disable refcount test with is_jython check. ........ r5308 | otmarhumbel | 2008-09-09 18:34:55 -0400 (Tue, 09 Sep 2008) | 1 line applied leosoto's patch from http://bugs.jython.org/issue1077 to avoid duplicate entries in jython-complete.jar ........ Modified Paths: -------------- branches/Release_2_5maint/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java branches/Release_2_5maint/jython/Lib/random.py branches/Release_2_5maint/jython/Lib/test/test_ast.py branches/Release_2_5maint/jython/Lib/test/test_class_jy.py branches/Release_2_5maint/jython/build.xml branches/Release_2_5maint/jython/src/org/python/antlr/PythonTokenSource.java branches/Release_2_5maint/jython/src/org/python/core/PyJavaClass.java branches/Release_2_5maint/jython/src/shell/jython.bat branches/Release_2_5maint/website/Project/index.txt Added Paths: ----------- branches/Release_2_5maint/jython/Lib/test/test_os.py Removed Paths: ------------- branches/Release_2_5maint/website/jeps/ Property Changed: ---------------- branches/Release_2_5maint/ Property changes on: branches/Release_2_5maint ___________________________________________________________________ Modified: svnmerge-integrated - /trunk:1-5297 + /trunk:1-5309 Modified: branches/Release_2_5maint/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java =================================================================== --- branches/Release_2_5maint/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java 2008-09-10 03:43:18 UTC (rev 5309) +++ branches/Release_2_5maint/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java 2008-09-10 03:59:17 UTC (rev 5310) @@ -44,8 +44,8 @@ buf.append("# Created on " + AT_DATE + " by " + System.getProperty("user.name") + "\n"); buf.append("\n"); buf.append("\"C:\\target/jython\" \"C:\\target/Tools/jythonc/jythonc.py\" \"$@\"\n"); - assertEquals(buf.toString().replaceAll(AT_DATE, new Date().toString()), _generator - .getJythoncScript(StartScriptGenerator.UNIX_FLAVOUR)); +// assertEquals(buf.toString().replaceAll(AT_DATE, new Date().toString()), _generator +// .getJythoncScript(StartScriptGenerator.UNIX_FLAVOUR)); } public void testWindows() throws IOException { @@ -75,8 +75,8 @@ buf = new StringBuffer(100); buf.append(winBuf); buf.append("\"C:\\target\\jython.bat\" \"C:\\target\\Tools\\jythonc\\jythonc.py\" %ARGS%"+WIN_CR_LF); - assertEquals(buf.toString().replaceAll(AT_DATE, new Date().toString()), _generator - .getJythoncScript(StartScriptGenerator.WINDOWS_FLAVOUR)); +// assertEquals(buf.toString().replaceAll(AT_DATE, new Date().toString()), _generator +// .getJythoncScript(StartScriptGenerator.WINDOWS_FLAVOUR)); } public void testFlavour() { Modified: branches/Release_2_5maint/jython/Lib/random.py =================================================================== --- branches/Release_2_5maint/jython/Lib/random.py 2008-09-10 03:43:18 UTC (rev 5309) +++ branches/Release_2_5maint/jython/Lib/random.py 2008-09-10 03:59:17 UTC (rev 5310) @@ -43,7 +43,10 @@ from math import log as _log, exp as _exp, pi as _pi, e as _e from math import sqrt as _sqrt, acos as _acos, cos as _cos, sin as _sin from math import floor as _floor +from os import urandom as _urandom +from binascii import hexlify as _hexlify + __all__ = ["Random","seed","random","uniform","randint","choice","sample", "randrange","shuffle","normalvariate","lognormvariate", "cunifvariate","expovariate","vonmisesvariate","gammavariate", @@ -55,6 +58,7 @@ LOG4 = _log(4.0) SG_MAGICCONST = 1.0 + _log(4.5) BPF = 53 # Number of bits in a float +RECIP_BPF = 2**-BPF # Translated by Guido van Rossum from C source provided by # Adrian Baddeley. Adapted by Raymond Hettinger for use with @@ -768,24 +772,37 @@ ## --------------- Operating System Random Source ------------------ class SystemRandom(Random): + """Alternate random number generator using sources provided + by the operating system (such as /dev/urandom on Unix or + CryptGenRandom on Windows). + + Not available on all systems (see os.urandom() for details). """ - XXX: throw NotImplementedError for any attemt to use this for now. - """ def random(self): - self._notimplemented() + """Get the next random number in the range [0.0, 1.0).""" + return (long(_hexlify(_urandom(7)), 16) >> 3) * RECIP_BPF def getrandbits(self, k): - self._notimplemented() + """getrandbits(k) -> x. Generates a long int with k random bits.""" + if k <= 0: + raise ValueError('number of bits must be greater than zero') + if k != int(k): + raise TypeError('number of bits should be an integer') + bytes = (k + 7) // 8 # bits / 8 and rounded up + x = long(_hexlify(_urandom(bytes)), 16) + return x >> (bytes * 8 - k) # trim excess bits def _stub(self, *args, **kwds): - self._notimplemented() + "Stub method. Not used for a system random number generator." + return None + seed = jumpahead = _stub def _notimplemented(self, *args, **kwds): - raise NotImplementedError('SystemRandom not implemented on Jython.') + "Method should not be called for a system random number generator." + raise NotImplementedError('System entropy source does not have state.') getstate = setstate = _notimplemented - ## -------------------- test program -------------------- def _test_generator(n, funccall): Modified: branches/Release_2_5maint/jython/Lib/test/test_ast.py =================================================================== --- branches/Release_2_5maint/jython/Lib/test/test_ast.py 2008-09-10 03:43:18 UTC (rev 5309) +++ branches/Release_2_5maint/jython/Lib/test/test_ast.py 2008-09-10 03:59:17 UTC (rev 5310) @@ -5,12 +5,12 @@ def get_class_name(t): result = t.__class__.__name__ if os.name.startswith('java'): - if result in ("org.python.antlr.ast.expr_contextType", - "org.python.antlr.ast.boolopType", - "org.python.antlr.ast.unaryopType", - "org.python.antlr.ast.cmpopType", - "org.python.antlr.ast.operatorType"): - result = str(t) + if result in ("expr_contextType", + "boolopType", + "unaryopType", + "cmpopType", + "operatorType"): + result = t.name() else: result = result.split(".")[-1] if result.endswith("Type"): Modified: branches/Release_2_5maint/jython/Lib/test/test_class_jy.py =================================================================== --- branches/Release_2_5maint/jython/Lib/test/test_class_jy.py 2008-09-10 03:43:18 UTC (rev 5309) +++ branches/Release_2_5maint/jython/Lib/test/test_class_jy.py 2008-09-10 03:59:17 UTC (rev 5310) @@ -273,12 +273,29 @@ self.assert_(isinstance(retro, OldStyle)) +class JavaClassNamingTestCase(unittest.TestCase): + """ + Tests for PyJavaClass naming. + """ + + def test_java_class_name(self): + """ + The __name__ and __module__ attributes of Java classes should be set + according to the same convention that Python uses. + """ + from java.lang import String + self.assertEqual(String.__name__, "String") + self.assertEqual(String.__module__, "java.lang") + + + def test_main(): test_support.run_unittest(ClassGeneralTestCase, ClassNamelessModuleTestCase, BrokenNameTestCase, ClassLocalsTestCase, - IsDescendentTestCase) + IsDescendentTestCase, + JavaClassNamingTestCase) if __name__ == "__main__": Copied: branches/Release_2_5maint/jython/Lib/test/test_os.py (from rev 5308, trunk/jython/Lib/test/test_os.py) =================================================================== --- branches/Release_2_5maint/jython/Lib/test/test_os.py (rev 0) +++ branches/Release_2_5maint/jython/Lib/test/test_os.py 2008-09-10 03:59:17 UTC (rev 5310) @@ -0,0 +1,494 @@ +# As a test suite for the os module, this is woefully inadequate, but this +# does add tests for a few functions which have been determined to be more +# portable than they had been thought to be. + +import os +import unittest +import warnings +import sys +from test import test_support + +warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, __name__) +warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, __name__) + +# Tests creating TESTFN +class FileTests(unittest.TestCase): + def setUp(self): + if os.path.exists(test_support.TESTFN): + os.unlink(test_support.TESTFN) + tearDown = setUp + + def test_access(self): + f = os.open(test_support.TESTFN, os.O_CREAT|os.O_RDWR) + os.close(f) + self.assert_(os.access(test_support.TESTFN, os.W_OK)) + + def test_rename(self): + path = unicode(test_support.TESTFN) + if not test_support.is_jython: + old = sys.getrefcount(path) + self.assertRaises(TypeError, os.rename, path, 0) + if not test_support.is_jython: + new = sys.getrefcount(path) + self.assertEqual(old, new) + + +class TemporaryFileTests(unittest.TestCase): + def setUp(self): + self.files = [] + os.mkdir(test_support.TESTFN) + + def tearDown(self): + for name in self.files: + os.unlink(name) + os.rmdir(test_support.TESTFN) + + def check_tempfile(self, name): + # make sure it doesn't already exist: + self.failIf(os.path.exists(name), + "file already exists for temporary file") + # make sure we can create the file + open(name, "w") + self.files.append(name) + + def test_tempnam(self): + if not hasattr(os, "tempnam"): + return + warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, + r"test_os$") + self.check_tempfile(os.tempnam()) + + name = os.tempnam(test_support.TESTFN) + self.check_tempfile(name) + + name = os.tempnam(test_support.TESTFN, "pfx") + self.assert_(os.path.basename(name)[:3] == "pfx") + self.check_tempfile(name) + + def test_tmpfile(self): + if not hasattr(os, "tmpfile"): + return + # As with test_tmpnam() below, the Windows implementation of tmpfile() + # attempts to create a file in the root directory of the current drive. + # On Vista and Server 2008, this test will always fail for normal users + # as writing to the root directory requires elevated privileges. With + # XP and below, the semantics of tmpfile() are the same, but the user + # running the test is more likely to have administrative privileges on + # their account already. If that's the case, then os.tmpfile() should + # work. In order to make this test as useful as possible, rather than + # trying to detect Windows versions or whether or not the user has the + # right permissions, just try and create a file in the root directory + # and see if it raises a 'Permission denied' OSError. If it does, then + # test that a subsequent call to os.tmpfile() raises the same error. If + # it doesn't, assume we're on XP or below and the user running the test + # has administrative privileges, and proceed with the test as normal. + if sys.platform == 'win32': + name = '\\python_test_os_test_tmpfile.txt' + if os.path.exists(name): + os.remove(name) + try: + fp = open(name, 'w') + except IOError, first: + # open() failed, assert tmpfile() fails in the same way. + # Although open() raises an IOError and os.tmpfile() raises an + # OSError(), 'args' will be (13, 'Permission denied') in both + # cases. + try: + fp = os.tmpfile() + except OSError, second: + self.assertEqual(first.args, second.args) + else: + self.fail("expected os.tmpfile() to raise OSError") + return + else: + # open() worked, therefore, tmpfile() should work. Close our + # dummy file and proceed with the test as normal. + fp.close() + os.remove(name) + + fp = os.tmpfile() + fp.write("foobar") + fp.seek(0,0) + s = fp.read() + fp.close() + self.assert_(s == "foobar") + + def test_tmpnam(self): + import sys + if not hasattr(os, "tmpnam"): + return + warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, + r"test_os$") + name = os.tmpnam() + if sys.platform in ("win32",): + # The Windows tmpnam() seems useless. From the MS docs: + # + # The character string that tmpnam creates consists of + # the path prefix, defined by the entry P_tmpdir in the + # file STDIO.H, followed by a sequence consisting of the + # digit characters '0' through '9'; the numerical value + # of this string is in the range 1 - 65,535. Changing the + # definitions of L_tmpnam or P_tmpdir in STDIO.H does not + # change the operation of tmpnam. + # + # The really bizarre part is that, at least under MSVC6, + # P_tmpdir is "\\". That is, the path returned refers to + # the root of the current drive. That's a terrible place to + # put temp files, and, depending on privileges, the user + # may not even be able to open a file in the root directory. + self.failIf(os.path.exists(name), + "file already exists for temporary file") + else: + self.check_tempfile(name) + +# Test attributes on return values from os.*stat* family. +class StatAttributeTests(unittest.TestCase): + def setUp(self): + os.mkdir(test_support.TESTFN) + self.fname = os.path.join(test_support.TESTFN, "f1") + f = open(self.fname, 'wb') + f.write("ABC") + f.close() + + def tearDown(self): + os.unlink(self.fname) + os.rmdir(test_support.TESTFN) + + def test_stat_attributes(self): + if not hasattr(os, "stat"): + return + + import stat + result = os.stat(self.fname) + + # Make sure direct access works + self.assertEquals(result[stat.ST_SIZE], 3) + self.assertEquals(result.st_size, 3) + + import sys + + # Make sure all the attributes are there + members = dir(result) + for name in dir(stat): + if name[:3] == 'ST_': + attr = name.lower() + if name.endswith("TIME"): + def trunc(x): return int(x) + else: + def trunc(x): return x + self.assertEquals(trunc(getattr(result, attr)), + result[getattr(stat, name)]) + self.assert_(attr in members) + + try: + result[200] + self.fail("No exception thrown") + except IndexError: + pass + + # Make sure that assignment fails + try: + result.st_mode = 1 + self.fail("No exception thrown") + except TypeError: + pass + + try: + result.st_rdev = 1 + self.fail("No exception thrown") + except (AttributeError, TypeError): + pass + + try: + result.parrot = 1 + self.fail("No exception thrown") + except AttributeError: + pass + + # Use the stat_result constructor with a too-short tuple. + try: + result2 = os.stat_result((10,)) + self.fail("No exception thrown") + except TypeError: + pass + + # Use the constructr with a too-long tuple. + try: + result2 = os.stat_result((0,1,2,3,4,5,6,7,8,9,10,11,12,13,14)) + except TypeError: + pass + + + def test_statvfs_attributes(self): + if not hasattr(os, "statvfs"): + return + + import statvfs + try: + result = os.statvfs(self.fname) + except OSError, e: + # On AtheOS, glibc always returns ENOSYS + import errno + if e.errno == errno.ENOSYS: + return + + # Make sure direct access works + self.assertEquals(result.f_bfree, result[statvfs.F_BFREE]) + + # Make sure all the attributes are there + members = dir(result) + for name in dir(statvfs): + if name[:2] == 'F_': + attr = name.lower() + self.assertEquals(getattr(result, attr), + result[getattr(statvfs, name)]) + self.assert_(attr in members) + + # Make sure that assignment really fails + try: + result.f_bfree = 1 + self.fail("No exception thrown") + except TypeError: + pass + + try: + result.parrot = 1 + self.fail("No exception thrown") + except AttributeError: + pass + + # Use the constructor with a too-short tuple. + try: + result2 = os.statvfs_result((10,)) + self.fail("No exception thrown") + except TypeError: + pass + + # Use the constructr with a too-long tuple. + try: + result2 = os.statvfs_result((0,1,2,3,4,5,6,7,8,9,10,11,12,13,14)) + except TypeError: + pass + + # Restrict test to Win32, since there is no guarantee other + # systems support centiseconds + if sys.platform == 'win32': + def get_file_system(path): + root = os.path.splitdrive(os.path.abspath(path))[0] + '\\' + import ctypes + kernel32 = ctypes.windll.kernel32 + buf = ctypes.create_string_buffer("", 100) + if kernel32.GetVolumeInformationA(root, None, 0, None, None, None, buf, len(buf)): + return buf.value + + if get_file_system(test_support.TESTFN) == "NTFS": + def test_1565150(self): + t1 = 1159195039.25 + os.utime(self.fname, (t1, t1)) + self.assertEquals(os.stat(self.fname).st_mtime, t1) + + def test_1686475(self): + # Verify that an open file can be stat'ed + try: + os.stat(r"c:\pagefile.sys") + except WindowsError, e: + if e == 2: # file does not exist; cannot run test + return + self.fail("Could not stat pagefile.sys") + +from test import mapping_tests + +class EnvironTests(mapping_tests.BasicTestMappingProtocol): + """check that os.environ object conform to mapping protocol""" + type2test = None + def _reference(self): + return {"KEY1":"VALUE1", "KEY2":"VALUE2", "KEY3":"VALUE3"} + def _empty_mapping(self): + os.environ.clear() + return os.environ + def setUp(self): + self.__save = dict(os.environ) + os.environ.clear() + def tearDown(self): + os.environ.clear() + os.environ.update(self.__save) + + # Bug 1110478 + def test_update2(self): + if os.path.exists("/bin/sh"): + os.environ.update(HELLO="World") + value = os.popen("/bin/sh -c 'echo $HELLO'").read().strip() + self.assertEquals(value, "World") + +class WalkTests(unittest.TestCase): + """Tests for os.walk().""" + + def test_traversal(self): + import os + from os.path import join + + # Build: + # TESTFN/ a file kid and two directory kids + # tmp1 + # SUB1/ a file kid and a directory kid + # tmp2 + # SUB11/ no kids + # SUB2/ just a file kid + # tmp3 + sub1_path = join(test_support.TESTFN, "SUB1") + sub11_path = join(sub1_path, "SUB11") + sub2_path = join(test_support.TESTFN, "SUB2") + tmp1_path = join(test_support.TESTFN, "tmp1") + tmp2_path = join(sub1_path, "tmp2") + tmp3_path = join(sub2_path, "tmp3") + + # Create stuff. + os.makedirs(sub11_path) + os.makedirs(sub2_path) + for path in tmp1_path, tmp2_path, tmp3_path: + f = file(path, "w") + f.write("I'm " + path + " and proud of it. Blame test_os.\n") + f.close() + + # Walk top-down. + all = list(os.walk(test_support.TESTFN)) + self.assertEqual(len(all), 4) + # We can't know which order SUB1 and SUB2 will appear in. + # Not flipped: TESTFN, SUB1, SUB11, SUB2 + # flipped: TESTFN, SUB2, SUB1, SUB11 + flipped = all[0][1][0] != "SUB1" + all[0][1].sort() + self.assertEqual(all[0], (test_support.TESTFN, ["SUB1", "SUB2"], ["tmp1"])) + self.assertEqual(all[1 + flipped], (sub1_path, ["SUB11"], ["tmp2"])) + self.assertEqual(all[2 + flipped], (sub11_path, [], [])) + self.assertEqual(all[3 - 2 * flipped], (sub2_path, [], ["tmp3"])) + + # Prune the search. + all = [] + for root, dirs, files in os.walk(test_support.TESTFN): + all.append((root, dirs, files)) + # Don't descend into SUB1. + if 'SUB1' in dirs: + # Note that this also mutates the dirs we appended to all! + dirs.remove('SUB1') + self.assertEqual(len(all), 2) + self.assertEqual(all[0], (test_support.TESTFN, ["SUB2"], ["tmp1"])) + self.assertEqual(all[1], (sub2_path, [], ["tmp3"])) + + # Walk bottom-up. + all = list(os.walk(test_support.TESTFN, topdown=False)) + self.assertEqual(len(all), 4) + # We can't know which order SUB1 and SUB2 will appear in. + # Not flipped: SUB11, SUB1, SUB2, TESTFN + # flipped: SUB2, SUB11, SUB1, TESTFN + flipped = all[3][1][0] != "SUB1" + all[3][1].sort() + self.assertEqual(all[3], (test_support.TESTFN, ["SUB1", "SUB2"], ["tmp1"])) + self.assertEqual(all[flipped], (sub11_path, [], [])) + self.assertEqual(all[flipped + 1], (sub1_path, ["SUB11"], ["tmp2"])) + self.assertEqual(all[2 - 2 * flipped], (sub2_path, [], ["tmp3"])) + + # Tear everything down. This is a decent use for bottom-up on + # Windows, which doesn't have a recursive delete command. The + # (not so) subtlety is that rmdir will fail unless the dir's + # kids are removed first, so bottom up is essential. + for root, dirs, files in os.walk(test_support.TESTFN, topdown=False): + for name in files: + os.remove(join(root, name)) + for name in dirs: + os.rmdir(join(root, name)) + os.rmdir(test_support.TESTFN) + +class MakedirTests (unittest.TestCase): + def setUp(self): + os.mkdir(test_support.TESTFN) + + def test_makedir(self): + base = test_support.TESTFN + path = os.path.join(base, 'dir1', 'dir2', 'dir3') + os.makedirs(path) # Should work + path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4') + os.makedirs(path) + + # Try paths with a '.' in them + self.failUnlessRaises(OSError, os.makedirs, os.curdir) + path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4', 'dir5', os.curdir) + os.makedirs(path) + path = os.path.join(base, 'dir1', os.curdir, 'dir2', 'dir3', 'dir4', + 'dir5', 'dir6') + os.makedirs(path) + + + + + def tearDown(self): + path = os.path.join(test_support.TESTFN, 'dir1', 'dir2', 'dir3', + 'dir4', 'dir5', 'dir6') + # If the tests failed, the bottom-most directory ('../dir6') + # may not have been created, so we look for the outermost directory + # that exists. + while not os.path.exists(path) and path != test_support.TESTFN: + path = os.path.dirname(path) + + os.removedirs(path) + +class DevNullTests (unittest.TestCase): + def test_devnull(self): + f = file(os.devnull, 'w') + f.write('hello') + f.close() + f = file(os.devnull, 'r') + self.assertEqual(f.read(), '') + f.close() + +class URandomTests (unittest.TestCase): + def test_urandom(self): + try: + self.assertEqual(len(os.urandom(1)), 1) + self.assertEqual(len(os.urandom(10)), 10) + self.assertEqual(len(os.urandom(100)), 100) + self.assertEqual(len(os.urandom(1000)), 1000) + except NotImplementedError: + pass + +class Win32ErrorTests(unittest.TestCase): + def test_rename(self): + self.assertRaises(WindowsError, os.rename, test_support.TESTFN, test_support.TESTFN+".bak") + + def test_remove(self): + self.assertRaises(WindowsError, os.remove, test_support.TESTFN) + + def test_chdir(self): + self.assertRaises(WindowsError, os.chdir, test_support.TESTFN) + + def test_mkdir(self): + self.assertRaises(WindowsError, os.chdir, test_support.TESTFN) + + def test_utime(self): + self.assertRaises(WindowsError, os.utime, test_support.TESTFN, None) + + def test_access(self): + self.assertRaises(WindowsError, os.utime, test_support.TESTFN, 0) + + def test_chmod(self): + self.assertRaises(WindowsError, os.utime, test_support.TESTFN, 0) + +if sys.platform != 'win32': + class Win32ErrorTests(unittest.TestCase): + pass + +def test_main(): + test_support.run_unittest( + FileTests, + TemporaryFileTests, + StatAttributeTests, + EnvironTests, + WalkTests, + MakedirTests, + DevNullTests, + URandomTests, + Win32ErrorTests + ) + +if __name__ == "__main__": + test_main() Modified: branches/Release_2_5maint/jython/build.xml =================================================================== --- branches/Release_2_5maint/jython/build.xml 2008-09-10 03:43:18 UTC (rev 5309) +++ branches/Release_2_5maint/jython/build.xml 2008-09-10 03:59:17 UTC (rev 5310) @@ -533,9 +533,9 @@ </target> <target name="jar-complete" depends="compile,expose,jarjar"> - <jar destfile="${dist.dir}/jython-complete.jar"> + <jar destfile="${dist.dir}/jython-complete.jar" duplicate="preserve"> + <fileset dir="${exposed.dir}"/> <fileset dir="${compile.dir}"/> - <fileset dir="${exposed.dir}"/> <fileset dir="${jarjar.dir}"> </fileset> <manifest> @@ -557,9 +557,9 @@ </target> <target name="jar" depends="compile,expose,jarjar"> - <jar destfile="${dist.dir}/jython.jar"> + <jar destfile="${dist.dir}/jython.jar" duplicate="preserve"> + <fileset dir="${exposed.dir}"/> <fileset dir="${compile.dir}"/> - <fileset dir="${exposed.dir}"/> <fileset dir="${jarjar.dir}"> <include name="org/python/objectweb/asm/ClassReader.class" /> </fileset> Modified: branches/Release_2_5maint/jython/src/org/python/antlr/PythonTokenSource.java =================================================================== --- branches/Release_2_5maint/jython/src/org/python/antlr/PythonTokenSource.java 2008-09-10 03:43:18 UTC (rev 5309) +++ branches/Release_2_5maint/jython/src/org/python/antlr/PythonTokenSource.java 2008-09-10 03:59:17 UTC (rev 5310) @@ -154,6 +154,7 @@ private void handleEOF(CommonToken eof, CommonToken prev) { if (prev != null) { + eof.setStartIndex(prev.getStopIndex()); eof.setStopIndex(prev.getStopIndex()); } } @@ -258,9 +259,11 @@ private void handleIndents(int cpos, CommonToken t) { push(cpos); //System.out.println("push("+cpos+"): "+stackString()); - Token indent = new CommonToken(PythonParser.INDENT,""); + CommonToken indent = new CommonToken(PythonParser.INDENT,""); indent.setCharPositionInLine(t.getCharPositionInLine()); indent.setLine(t.getLine()); + indent.setStartIndex(t.getStartIndex() - 1); + indent.setStopIndex(t.getStartIndex() - 1); tokens.addElement(indent); } @@ -274,9 +277,8 @@ dedent.setCharPositionInLine(t.getCharPositionInLine()); dedent.setLine(t.getLine()); - //XXX: this will get messed up by comments. - dedent.setStartIndex(t.getStartIndex()); - dedent.setStopIndex(t.getStopIndex()); + dedent.setStartIndex(t.getStartIndex() - 1); + dedent.setStopIndex(t.getStartIndex() - 1); tokens.addElement(dedent); } Modified: branches/Release_2_5maint/jython/src/org/python/core/PyJavaClass.java =================================================================== --- branches/Release_2_5maint/jython/src/org/python/core/PyJavaClass.java 2008-09-10 03:43:18 UTC (rev 5309) +++ branches/Release_2_5maint/jython/src/org/python/core/PyJavaClass.java 2008-09-10 03:59:17 UTC (rev 5310) @@ -75,8 +75,30 @@ init(c); } - protected PyJavaClass(String name,PackageManager mgr) { - __name__ = name; + public String __module__; + /** + * Set the full name of this class. + */ + private void setName(String name) { + int dotIndex = name.lastIndexOf("."); + if (dotIndex == -1) { + __name__ = name; + __module__ = ""; + } else { + __name__ = name.substring(name.lastIndexOf(".")+1, name.length()); + __module__ = name.substring(0, name.lastIndexOf(".")); + } + } + + private String fullName() { + if (__module__ == "") + return __name__; + else + return __module__ + "." + __name__; + } + + protected PyJavaClass(String name, PackageManager mgr) { + setName(name); this.__mgr__ = mgr; } @@ -97,7 +119,7 @@ } private static final void initLazy(PyJavaClass jc) { - Class c = jc.__mgr__.findClass(null,jc.__name__,"lazy java class"); + Class c = jc.__mgr__.findClass(null,jc.fullName(),"lazy java class"); check_lazy_allowed(c); // xxx jc.init(c); tbl.putCanonical(jc.proxyClass,jc); @@ -209,7 +231,7 @@ private void init(Class c) { proxyClass = c; - __name__ = c.getName(); + setName(c.getName()); } /** @@ -761,6 +783,8 @@ } if (name == "__name__") return new PyString(__name__); + if (name == "__module__") + return new PyString(__module__); if (name == "__bases__") { if (__bases__ == null) initialize(); @@ -851,11 +875,11 @@ if (PyObject.class.isAssignableFrom(proxyClass)) { if (Modifier.isAbstract(proxyClass.getModifiers())) { throw Py.TypeError("can't instantiate abstract class ("+ - __name__+")"); + fullName()+")"); } if (__init__ == null) { throw Py.TypeError("no public constructors for "+ - __name__); + fullName()); } return __init__.make(args,keywords); } @@ -871,7 +895,19 @@ return super.__tojava__(c); } + public int __cmp__(PyObject other) { + if (!(other instanceof PyJavaClass)) { + return -2; + } + int c = fullName().compareTo(((PyJavaClass) other).fullName()); + return c < 0 ? -1 : c > 0 ? 1 : 0; + } + + public PyString __str__() { + return new PyString(fullName()); + } + public String toString() { - return "<jclass "+__name__+" "+Py.idstr(this)+">"; + return "<jclass "+fullName()+" "+Py.idstr(this)+">"; } } Modified: branches/Release_2_5maint/jython/src/shell/jython.bat =================================================================== --- branches/Release_2_5maint/jython/src/shell/jython.bat 2008-09-10 03:43:18 UTC (rev 5309) +++ branches/Release_2_5maint/jython/src/shell/jython.bat 2008-09-10 03:59:17 UTC (rev 5310) @@ -17,12 +17,12 @@ rem ----- Verify and set required environment variables ----------------------- set _JAVA_CMD=java -if not "%JAVA_HOME%" == "" ( +if not [%JAVA_HOME%] == [] ( set _JAVA_CMD="%JAVA_HOME:"=%\bin\java" ) set _JYTHON_HOME=%JYTHON_HOME% -if not "%JYTHON_HOME%" == "" goto gotHome +if not [%JYTHON_HOME%] == [] goto gotHome pushd "%~dp0%\.." set _JYTHON_HOME="%CD%" popd @@ -84,7 +84,7 @@ if ["%_CMP%"] == ["--"] goto argsDone if ["%_CMP%"] == ["--jdb"] ( - if "%JAVA_HOME%" == "" ( + if [%JAVA_HOME%] == [] ( set _JAVA_CMD=jdb ) else ( set _JAVA_CMD="%_JAVA_HOME:"=%\bin\jdb" Modified: branches/Release_2_5maint/website/Project/index.txt =================================================================== --- branches/Release_2_5maint/website/Project/index.txt 2008-09-10 03:43:18 UTC (rev 5309) +++ branches/Release_2_5maint/website/Project/index.txt 2008-09-10 03:59:17 UTC (rev 5310) @@ -11,8 +11,12 @@ .. admonition:: Latest News - The Jython development team is proud to announce a new release: Jython 2.2.1! + The Jython development team is proud to announce a new alpha release: Jython 2.5a2! + * `Test the alpha <http://downloads.sourceforge.net/jython/jython_installer-2.5a2.jar>`__ + + For production use please continue to use Jython 2.2.1 + * `Download location`_ * `Installation instructions <installation.html>`__ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-10 03:43:21
|
Revision: 5309 http://jython.svn.sourceforge.net/jython/?rev=5309&view=rev Author: fwierzbicki Date: 2008-09-10 03:43:18 +0000 (Wed, 10 Sep 2008) Log Message: ----------- Initialized merge tracking via "svnmerge" with revisions "1-5297" from https://jython.svn.sourceforge.net/svnroot/jython/trunk Property Changed: ---------------- branches/Release_2_5maint/ Property changes on: branches/Release_2_5maint ___________________________________________________________________ Added: svnmerge-integrated + /trunk:1-5297 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2008-09-09 22:34:58
|
Revision: 5308 http://jython.svn.sourceforge.net/jython/?rev=5308&view=rev Author: otmarhumbel Date: 2008-09-09 22:34:55 +0000 (Tue, 09 Sep 2008) Log Message: ----------- applied leosoto's patch from http://bugs.jython.org/issue1077 to avoid duplicate entries in jython-complete.jar Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2008-09-09 21:15:54 UTC (rev 5307) +++ trunk/jython/build.xml 2008-09-09 22:34:55 UTC (rev 5308) @@ -533,9 +533,9 @@ </target> <target name="jar-complete" depends="compile,expose,jarjar"> - <jar destfile="${dist.dir}/jython-complete.jar"> + <jar destfile="${dist.dir}/jython-complete.jar" duplicate="preserve"> + <fileset dir="${exposed.dir}"/> <fileset dir="${compile.dir}"/> - <fileset dir="${exposed.dir}"/> <fileset dir="${jarjar.dir}"> </fileset> <manifest> @@ -557,9 +557,9 @@ </target> <target name="jar" depends="compile,expose,jarjar"> - <jar destfile="${dist.dir}/jython.jar"> + <jar destfile="${dist.dir}/jython.jar" duplicate="preserve"> + <fileset dir="${exposed.dir}"/> <fileset dir="${compile.dir}"/> - <fileset dir="${exposed.dir}"/> <fileset dir="${jarjar.dir}"> <include name="org/python/objectweb/asm/ClassReader.class" /> </fileset> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-09 21:15:57
|
Revision: 5307 http://jython.svn.sourceforge.net/jython/?rev=5307&view=rev Author: fwierzbicki Date: 2008-09-09 21:15:54 +0000 (Tue, 09 Sep 2008) Log Message: ----------- Disable refcount test with is_jython check. Modified Paths: -------------- trunk/jython/Lib/test/test_os.py Modified: trunk/jython/Lib/test/test_os.py =================================================================== --- trunk/jython/Lib/test/test_os.py 2008-09-09 20:35:30 UTC (rev 5306) +++ trunk/jython/Lib/test/test_os.py 2008-09-09 21:15:54 UTC (rev 5307) @@ -25,10 +25,12 @@ def test_rename(self): path = unicode(test_support.TESTFN) - old = sys.getrefcount(path) + if not test_support.is_jython: + old = sys.getrefcount(path) self.assertRaises(TypeError, os.rename, path, 0) - new = sys.getrefcount(path) - self.assertEqual(old, new) + if not test_support.is_jython: + new = sys.getrefcount(path) + self.assertEqual(old, new) class TemporaryFileTests(unittest.TestCase): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2008-09-09 20:35:33
|
Revision: 5306 http://jython.svn.sourceforge.net/jython/?rev=5306&view=rev Author: otmarhumbel Date: 2008-09-09 20:35:30 +0000 (Tue, 09 Sep 2008) Log Message: ----------- enable compilation for full-build (-A is still broken) Modified Paths: -------------- trunk/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java Modified: trunk/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java =================================================================== --- trunk/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java 2008-09-09 19:06:17 UTC (rev 5305) +++ trunk/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java 2008-09-09 20:35:30 UTC (rev 5306) @@ -44,8 +44,8 @@ buf.append("# Created on " + AT_DATE + " by " + System.getProperty("user.name") + "\n"); buf.append("\n"); buf.append("\"C:\\target/jython\" \"C:\\target/Tools/jythonc/jythonc.py\" \"$@\"\n"); - assertEquals(buf.toString().replaceAll(AT_DATE, new Date().toString()), _generator - .getJythoncScript(StartScriptGenerator.UNIX_FLAVOUR)); +// assertEquals(buf.toString().replaceAll(AT_DATE, new Date().toString()), _generator +// .getJythoncScript(StartScriptGenerator.UNIX_FLAVOUR)); } public void testWindows() throws IOException { @@ -75,8 +75,8 @@ buf = new StringBuffer(100); buf.append(winBuf); buf.append("\"C:\\target\\jython.bat\" \"C:\\target\\Tools\\jythonc\\jythonc.py\" %ARGS%"+WIN_CR_LF); - assertEquals(buf.toString().replaceAll(AT_DATE, new Date().toString()), _generator - .getJythoncScript(StartScriptGenerator.WINDOWS_FLAVOUR)); +// assertEquals(buf.toString().replaceAll(AT_DATE, new Date().toString()), _generator +// .getJythoncScript(StartScriptGenerator.WINDOWS_FLAVOUR)); } public void testFlavour() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-09 19:06:20
|
Revision: 5305 http://jython.svn.sourceforge.net/jython/?rev=5305&view=rev Author: fwierzbicki Date: 2008-09-09 19:06:17 +0000 (Tue, 09 Sep 2008) Log Message: ----------- from: http://svn.python.org/projects/python/branches/release25-maint/Lib@66318 Added Paths: ----------- trunk/jython/Lib/test/test_os.py Added: trunk/jython/Lib/test/test_os.py =================================================================== --- trunk/jython/Lib/test/test_os.py (rev 0) +++ trunk/jython/Lib/test/test_os.py 2008-09-09 19:06:17 UTC (rev 5305) @@ -0,0 +1,492 @@ +# As a test suite for the os module, this is woefully inadequate, but this +# does add tests for a few functions which have been determined to be more +# portable than they had been thought to be. + +import os +import unittest +import warnings +import sys +from test import test_support + +warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, __name__) +warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, __name__) + +# Tests creating TESTFN +class FileTests(unittest.TestCase): + def setUp(self): + if os.path.exists(test_support.TESTFN): + os.unlink(test_support.TESTFN) + tearDown = setUp + + def test_access(self): + f = os.open(test_support.TESTFN, os.O_CREAT|os.O_RDWR) + os.close(f) + self.assert_(os.access(test_support.TESTFN, os.W_OK)) + + def test_rename(self): + path = unicode(test_support.TESTFN) + old = sys.getrefcount(path) + self.assertRaises(TypeError, os.rename, path, 0) + new = sys.getrefcount(path) + self.assertEqual(old, new) + + +class TemporaryFileTests(unittest.TestCase): + def setUp(self): + self.files = [] + os.mkdir(test_support.TESTFN) + + def tearDown(self): + for name in self.files: + os.unlink(name) + os.rmdir(test_support.TESTFN) + + def check_tempfile(self, name): + # make sure it doesn't already exist: + self.failIf(os.path.exists(name), + "file already exists for temporary file") + # make sure we can create the file + open(name, "w") + self.files.append(name) + + def test_tempnam(self): + if not hasattr(os, "tempnam"): + return + warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, + r"test_os$") + self.check_tempfile(os.tempnam()) + + name = os.tempnam(test_support.TESTFN) + self.check_tempfile(name) + + name = os.tempnam(test_support.TESTFN, "pfx") + self.assert_(os.path.basename(name)[:3] == "pfx") + self.check_tempfile(name) + + def test_tmpfile(self): + if not hasattr(os, "tmpfile"): + return + # As with test_tmpnam() below, the Windows implementation of tmpfile() + # attempts to create a file in the root directory of the current drive. + # On Vista and Server 2008, this test will always fail for normal users + # as writing to the root directory requires elevated privileges. With + # XP and below, the semantics of tmpfile() are the same, but the user + # running the test is more likely to have administrative privileges on + # their account already. If that's the case, then os.tmpfile() should + # work. In order to make this test as useful as possible, rather than + # trying to detect Windows versions or whether or not the user has the + # right permissions, just try and create a file in the root directory + # and see if it raises a 'Permission denied' OSError. If it does, then + # test that a subsequent call to os.tmpfile() raises the same error. If + # it doesn't, assume we're on XP or below and the user running the test + # has administrative privileges, and proceed with the test as normal. + if sys.platform == 'win32': + name = '\\python_test_os_test_tmpfile.txt' + if os.path.exists(name): + os.remove(name) + try: + fp = open(name, 'w') + except IOError, first: + # open() failed, assert tmpfile() fails in the same way. + # Although open() raises an IOError and os.tmpfile() raises an + # OSError(), 'args' will be (13, 'Permission denied') in both + # cases. + try: + fp = os.tmpfile() + except OSError, second: + self.assertEqual(first.args, second.args) + else: + self.fail("expected os.tmpfile() to raise OSError") + return + else: + # open() worked, therefore, tmpfile() should work. Close our + # dummy file and proceed with the test as normal. + fp.close() + os.remove(name) + + fp = os.tmpfile() + fp.write("foobar") + fp.seek(0,0) + s = fp.read() + fp.close() + self.assert_(s == "foobar") + + def test_tmpnam(self): + import sys + if not hasattr(os, "tmpnam"): + return + warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, + r"test_os$") + name = os.tmpnam() + if sys.platform in ("win32",): + # The Windows tmpnam() seems useless. From the MS docs: + # + # The character string that tmpnam creates consists of + # the path prefix, defined by the entry P_tmpdir in the + # file STDIO.H, followed by a sequence consisting of the + # digit characters '0' through '9'; the numerical value + # of this string is in the range 1 - 65,535. Changing the + # definitions of L_tmpnam or P_tmpdir in STDIO.H does not + # change the operation of tmpnam. + # + # The really bizarre part is that, at least under MSVC6, + # P_tmpdir is "\\". That is, the path returned refers to + # the root of the current drive. That's a terrible place to + # put temp files, and, depending on privileges, the user + # may not even be able to open a file in the root directory. + self.failIf(os.path.exists(name), + "file already exists for temporary file") + else: + self.check_tempfile(name) + +# Test attributes on return values from os.*stat* family. +class StatAttributeTests(unittest.TestCase): + def setUp(self): + os.mkdir(test_support.TESTFN) + self.fname = os.path.join(test_support.TESTFN, "f1") + f = open(self.fname, 'wb') + f.write("ABC") + f.close() + + def tearDown(self): + os.unlink(self.fname) + os.rmdir(test_support.TESTFN) + + def test_stat_attributes(self): + if not hasattr(os, "stat"): + return + + import stat + result = os.stat(self.fname) + + # Make sure direct access works + self.assertEquals(result[stat.ST_SIZE], 3) + self.assertEquals(result.st_size, 3) + + import sys + + # Make sure all the attributes are there + members = dir(result) + for name in dir(stat): + if name[:3] == 'ST_': + attr = name.lower() + if name.endswith("TIME"): + def trunc(x): return int(x) + else: + def trunc(x): return x + self.assertEquals(trunc(getattr(result, attr)), + result[getattr(stat, name)]) + self.assert_(attr in members) + + try: + result[200] + self.fail("No exception thrown") + except IndexError: + pass + + # Make sure that assignment fails + try: + result.st_mode = 1 + self.fail("No exception thrown") + except TypeError: + pass + + try: + result.st_rdev = 1 + self.fail("No exception thrown") + except (AttributeError, TypeError): + pass + + try: + result.parrot = 1 + self.fail("No exception thrown") + except AttributeError: + pass + + # Use the stat_result constructor with a too-short tuple. + try: + result2 = os.stat_result((10,)) + self.fail("No exception thrown") + except TypeError: + pass + + # Use the constructr with a too-long tuple. + try: + result2 = os.stat_result((0,1,2,3,4,5,6,7,8,9,10,11,12,13,14)) + except TypeError: + pass + + + def test_statvfs_attributes(self): + if not hasattr(os, "statvfs"): + return + + import statvfs + try: + result = os.statvfs(self.fname) + except OSError, e: + # On AtheOS, glibc always returns ENOSYS + import errno + if e.errno == errno.ENOSYS: + return + + # Make sure direct access works + self.assertEquals(result.f_bfree, result[statvfs.F_BFREE]) + + # Make sure all the attributes are there + members = dir(result) + for name in dir(statvfs): + if name[:2] == 'F_': + attr = name.lower() + self.assertEquals(getattr(result, attr), + result[getattr(statvfs, name)]) + self.assert_(attr in members) + + # Make sure that assignment really fails + try: + result.f_bfree = 1 + self.fail("No exception thrown") + except TypeError: + pass + + try: + result.parrot = 1 + self.fail("No exception thrown") + except AttributeError: + pass + + # Use the constructor with a too-short tuple. + try: + result2 = os.statvfs_result((10,)) + self.fail("No exception thrown") + except TypeError: + pass + + # Use the constructr with a too-long tuple. + try: + result2 = os.statvfs_result((0,1,2,3,4,5,6,7,8,9,10,11,12,13,14)) + except TypeError: + pass + + # Restrict test to Win32, since there is no guarantee other + # systems support centiseconds + if sys.platform == 'win32': + def get_file_system(path): + root = os.path.splitdrive(os.path.abspath(path))[0] + '\\' + import ctypes + kernel32 = ctypes.windll.kernel32 + buf = ctypes.create_string_buffer("", 100) + if kernel32.GetVolumeInformationA(root, None, 0, None, None, None, buf, len(buf)): + return buf.value + + if get_file_system(test_support.TESTFN) == "NTFS": + def test_1565150(self): + t1 = 1159195039.25 + os.utime(self.fname, (t1, t1)) + self.assertEquals(os.stat(self.fname).st_mtime, t1) + + def test_1686475(self): + # Verify that an open file can be stat'ed + try: + os.stat(r"c:\pagefile.sys") + except WindowsError, e: + if e == 2: # file does not exist; cannot run test + return + self.fail("Could not stat pagefile.sys") + +from test import mapping_tests + +class EnvironTests(mapping_tests.BasicTestMappingProtocol): + """check that os.environ object conform to mapping protocol""" + type2test = None + def _reference(self): + return {"KEY1":"VALUE1", "KEY2":"VALUE2", "KEY3":"VALUE3"} + def _empty_mapping(self): + os.environ.clear() + return os.environ + def setUp(self): + self.__save = dict(os.environ) + os.environ.clear() + def tearDown(self): + os.environ.clear() + os.environ.update(self.__save) + + # Bug 1110478 + def test_update2(self): + if os.path.exists("/bin/sh"): + os.environ.update(HELLO="World") + value = os.popen("/bin/sh -c 'echo $HELLO'").read().strip() + self.assertEquals(value, "World") + +class WalkTests(unittest.TestCase): + """Tests for os.walk().""" + + def test_traversal(self): + import os + from os.path import join + + # Build: + # TESTFN/ a file kid and two directory kids + # tmp1 + # SUB1/ a file kid and a directory kid + # tmp2 + # SUB11/ no kids + # SUB2/ just a file kid + # tmp3 + sub1_path = join(test_support.TESTFN, "SUB1") + sub11_path = join(sub1_path, "SUB11") + sub2_path = join(test_support.TESTFN, "SUB2") + tmp1_path = join(test_support.TESTFN, "tmp1") + tmp2_path = join(sub1_path, "tmp2") + tmp3_path = join(sub2_path, "tmp3") + + # Create stuff. + os.makedirs(sub11_path) + os.makedirs(sub2_path) + for path in tmp1_path, tmp2_path, tmp3_path: + f = file(path, "w") + f.write("I'm " + path + " and proud of it. Blame test_os.\n") + f.close() + + # Walk top-down. + all = list(os.walk(test_support.TESTFN)) + self.assertEqual(len(all), 4) + # We can't know which order SUB1 and SUB2 will appear in. + # Not flipped: TESTFN, SUB1, SUB11, SUB2 + # flipped: TESTFN, SUB2, SUB1, SUB11 + flipped = all[0][1][0] != "SUB1" + all[0][1].sort() + self.assertEqual(all[0], (test_support.TESTFN, ["SUB1", "SUB2"], ["tmp1"])) + self.assertEqual(all[1 + flipped], (sub1_path, ["SUB11"], ["tmp2"])) + self.assertEqual(all[2 + flipped], (sub11_path, [], [])) + self.assertEqual(all[3 - 2 * flipped], (sub2_path, [], ["tmp3"])) + + # Prune the search. + all = [] + for root, dirs, files in os.walk(test_support.TESTFN): + all.append((root, dirs, files)) + # Don't descend into SUB1. + if 'SUB1' in dirs: + # Note that this also mutates the dirs we appended to all! + dirs.remove('SUB1') + self.assertEqual(len(all), 2) + self.assertEqual(all[0], (test_support.TESTFN, ["SUB2"], ["tmp1"])) + self.assertEqual(all[1], (sub2_path, [], ["tmp3"])) + + # Walk bottom-up. + all = list(os.walk(test_support.TESTFN, topdown=False)) + self.assertEqual(len(all), 4) + # We can't know which order SUB1 and SUB2 will appear in. + # Not flipped: SUB11, SUB1, SUB2, TESTFN + # flipped: SUB2, SUB11, SUB1, TESTFN + flipped = all[3][1][0] != "SUB1" + all[3][1].sort() + self.assertEqual(all[3], (test_support.TESTFN, ["SUB1", "SUB2"], ["tmp1"])) + self.assertEqual(all[flipped], (sub11_path, [], [])) + self.assertEqual(all[flipped + 1], (sub1_path, ["SUB11"], ["tmp2"])) + self.assertEqual(all[2 - 2 * flipped], (sub2_path, [], ["tmp3"])) + + # Tear everything down. This is a decent use for bottom-up on + # Windows, which doesn't have a recursive delete command. The + # (not so) subtlety is that rmdir will fail unless the dir's + # kids are removed first, so bottom up is essential. + for root, dirs, files in os.walk(test_support.TESTFN, topdown=False): + for name in files: + os.remove(join(root, name)) + for name in dirs: + os.rmdir(join(root, name)) + os.rmdir(test_support.TESTFN) + +class MakedirTests (unittest.TestCase): + def setUp(self): + os.mkdir(test_support.TESTFN) + + def test_makedir(self): + base = test_support.TESTFN + path = os.path.join(base, 'dir1', 'dir2', 'dir3') + os.makedirs(path) # Should work + path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4') + os.makedirs(path) + + # Try paths with a '.' in them + self.failUnlessRaises(OSError, os.makedirs, os.curdir) + path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4', 'dir5', os.curdir) + os.makedirs(path) + path = os.path.join(base, 'dir1', os.curdir, 'dir2', 'dir3', 'dir4', + 'dir5', 'dir6') + os.makedirs(path) + + + + + def tearDown(self): + path = os.path.join(test_support.TESTFN, 'dir1', 'dir2', 'dir3', + 'dir4', 'dir5', 'dir6') + # If the tests failed, the bottom-most directory ('../dir6') + # may not have been created, so we look for the outermost directory + # that exists. + while not os.path.exists(path) and path != test_support.TESTFN: + path = os.path.dirname(path) + + os.removedirs(path) + +class DevNullTests (unittest.TestCase): + def test_devnull(self): + f = file(os.devnull, 'w') + f.write('hello') + f.close() + f = file(os.devnull, 'r') + self.assertEqual(f.read(), '') + f.close() + +class URandomTests (unittest.TestCase): + def test_urandom(self): + try: + self.assertEqual(len(os.urandom(1)), 1) + self.assertEqual(len(os.urandom(10)), 10) + self.assertEqual(len(os.urandom(100)), 100) + self.assertEqual(len(os.urandom(1000)), 1000) + except NotImplementedError: + pass + +class Win32ErrorTests(unittest.TestCase): + def test_rename(self): + self.assertRaises(WindowsError, os.rename, test_support.TESTFN, test_support.TESTFN+".bak") + + def test_remove(self): + self.assertRaises(WindowsError, os.remove, test_support.TESTFN) + + def test_chdir(self): + self.assertRaises(WindowsError, os.chdir, test_support.TESTFN) + + def test_mkdir(self): + self.assertRaises(WindowsError, os.chdir, test_support.TESTFN) + + def test_utime(self): + self.assertRaises(WindowsError, os.utime, test_support.TESTFN, None) + + def test_access(self): + self.assertRaises(WindowsError, os.utime, test_support.TESTFN, 0) + + def test_chmod(self): + self.assertRaises(WindowsError, os.utime, test_support.TESTFN, 0) + +if sys.platform != 'win32': + class Win32ErrorTests(unittest.TestCase): + pass + +def test_main(): + test_support.run_unittest( + FileTests, + TemporaryFileTests, + StatAttributeTests, + EnvironTests, + WalkTests, + MakedirTests, + DevNullTests, + URandomTests, + Win32ErrorTests + ) + +if __name__ == "__main__": + test_main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-09 18:43:02
|
Revision: 5304 http://jython.svn.sourceforge.net/jython/?rev=5304&view=rev Author: fwierzbicki Date: 2008-09-09 18:42:57 +0000 (Tue, 09 Sep 2008) Log Message: ----------- Fix some offset problems in DEDENT, INDENT, and EOF. Modified Paths: -------------- trunk/jython/src/org/python/antlr/PythonTokenSource.java Modified: trunk/jython/src/org/python/antlr/PythonTokenSource.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTokenSource.java 2008-09-08 17:48:28 UTC (rev 5303) +++ trunk/jython/src/org/python/antlr/PythonTokenSource.java 2008-09-09 18:42:57 UTC (rev 5304) @@ -154,6 +154,7 @@ private void handleEOF(CommonToken eof, CommonToken prev) { if (prev != null) { + eof.setStartIndex(prev.getStopIndex()); eof.setStopIndex(prev.getStopIndex()); } } @@ -258,9 +259,11 @@ private void handleIndents(int cpos, CommonToken t) { push(cpos); //System.out.println("push("+cpos+"): "+stackString()); - Token indent = new CommonToken(PythonParser.INDENT,""); + CommonToken indent = new CommonToken(PythonParser.INDENT,""); indent.setCharPositionInLine(t.getCharPositionInLine()); indent.setLine(t.getLine()); + indent.setStartIndex(t.getStartIndex() - 1); + indent.setStopIndex(t.getStartIndex() - 1); tokens.addElement(indent); } @@ -274,9 +277,8 @@ dedent.setCharPositionInLine(t.getCharPositionInLine()); dedent.setLine(t.getLine()); - //XXX: this will get messed up by comments. - dedent.setStartIndex(t.getStartIndex()); - dedent.setStopIndex(t.getStopIndex()); + dedent.setStartIndex(t.getStartIndex() - 1); + dedent.setStopIndex(t.getStartIndex() - 1); tokens.addElement(dedent); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-09-08 17:48:31
|
Revision: 5303 http://jython.svn.sourceforge.net/jython/?rev=5303&view=rev Author: leosoto Date: 2008-09-08 17:48:28 +0000 (Mon, 08 Sep 2008) Log Message: ----------- SystemRandom implementation taken from CPython. It depends on urandom(), which seems supported now through jna-posix Modified Paths: -------------- trunk/jython/Lib/random.py Modified: trunk/jython/Lib/random.py =================================================================== --- trunk/jython/Lib/random.py 2008-09-08 14:41:41 UTC (rev 5302) +++ trunk/jython/Lib/random.py 2008-09-08 17:48:28 UTC (rev 5303) @@ -43,7 +43,10 @@ from math import log as _log, exp as _exp, pi as _pi, e as _e from math import sqrt as _sqrt, acos as _acos, cos as _cos, sin as _sin from math import floor as _floor +from os import urandom as _urandom +from binascii import hexlify as _hexlify + __all__ = ["Random","seed","random","uniform","randint","choice","sample", "randrange","shuffle","normalvariate","lognormvariate", "cunifvariate","expovariate","vonmisesvariate","gammavariate", @@ -55,6 +58,7 @@ LOG4 = _log(4.0) SG_MAGICCONST = 1.0 + _log(4.5) BPF = 53 # Number of bits in a float +RECIP_BPF = 2**-BPF # Translated by Guido van Rossum from C source provided by # Adrian Baddeley. Adapted by Raymond Hettinger for use with @@ -768,24 +772,37 @@ ## --------------- Operating System Random Source ------------------ class SystemRandom(Random): + """Alternate random number generator using sources provided + by the operating system (such as /dev/urandom on Unix or + CryptGenRandom on Windows). + + Not available on all systems (see os.urandom() for details). """ - XXX: throw NotImplementedError for any attemt to use this for now. - """ def random(self): - self._notimplemented() + """Get the next random number in the range [0.0, 1.0).""" + return (long(_hexlify(_urandom(7)), 16) >> 3) * RECIP_BPF def getrandbits(self, k): - self._notimplemented() + """getrandbits(k) -> x. Generates a long int with k random bits.""" + if k <= 0: + raise ValueError('number of bits must be greater than zero') + if k != int(k): + raise TypeError('number of bits should be an integer') + bytes = (k + 7) // 8 # bits / 8 and rounded up + x = long(_hexlify(_urandom(bytes)), 16) + return x >> (bytes * 8 - k) # trim excess bits def _stub(self, *args, **kwds): - self._notimplemented() + "Stub method. Not used for a system random number generator." + return None + seed = jumpahead = _stub def _notimplemented(self, *args, **kwds): - raise NotImplementedError('SystemRandom not implemented on Jython.') + "Method should not be called for a system random number generator." + raise NotImplementedError('System entropy source does not have state.') getstate = setstate = _notimplemented - ## -------------------- test program -------------------- def _test_generator(n, funccall): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2008-09-08 14:41:44
|
Revision: 5302 http://jython.svn.sourceforge.net/jython/?rev=5302&view=rev Author: otmarhumbel Date: 2008-09-08 14:41:41 +0000 (Mon, 08 Sep 2008) Log Message: ----------- Fix for issue #1123: Weird "unexpected at this time" error. The tests if environment variables JAVA_HOME or JYTHON_HOME are set did not work: - if the path contained a space - if the variable really was not set The passed (manual, so far) tests can be found in: http://bugs.jython.org/msg3489 Modified Paths: -------------- trunk/jython/src/shell/jython.bat Modified: trunk/jython/src/shell/jython.bat =================================================================== --- trunk/jython/src/shell/jython.bat 2008-09-07 05:57:26 UTC (rev 5301) +++ trunk/jython/src/shell/jython.bat 2008-09-08 14:41:41 UTC (rev 5302) @@ -17,12 +17,12 @@ rem ----- Verify and set required environment variables ----------------------- set _JAVA_CMD=java -if not "%JAVA_HOME%" == "" ( +if not [%JAVA_HOME%] == [] ( set _JAVA_CMD="%JAVA_HOME:"=%\bin\java" ) set _JYTHON_HOME=%JYTHON_HOME% -if not "%JYTHON_HOME%" == "" goto gotHome +if not [%JYTHON_HOME%] == [] goto gotHome pushd "%~dp0%\.." set _JYTHON_HOME="%CD%" popd @@ -84,7 +84,7 @@ if ["%_CMP%"] == ["--"] goto argsDone if ["%_CMP%"] == ["--jdb"] ( - if "%JAVA_HOME%" == "" ( + if [%JAVA_HOME%] == [] ( set _JAVA_CMD=jdb ) else ( set _JAVA_CMD="%_JAVA_HOME:"=%\bin\jdb" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-07 05:57:30
|
Revision: 5301 http://jython.svn.sourceforge.net/jython/?rev=5301&view=rev Author: fwierzbicki Date: 2008-09-07 05:57:26 +0000 (Sun, 07 Sep 2008) Log Message: ----------- Committing Nicholas Riley's patch after getting test_ast.py to work. See http://bugs.jython.org/issue1758279. Modified Paths: -------------- trunk/jython/Lib/test/test_ast.py trunk/jython/Lib/test/test_class_jy.py trunk/jython/src/org/python/core/PyJavaClass.java Modified: trunk/jython/Lib/test/test_ast.py =================================================================== --- trunk/jython/Lib/test/test_ast.py 2008-09-06 23:20:46 UTC (rev 5300) +++ trunk/jython/Lib/test/test_ast.py 2008-09-07 05:57:26 UTC (rev 5301) @@ -5,12 +5,12 @@ def get_class_name(t): result = t.__class__.__name__ if os.name.startswith('java'): - if result in ("org.python.antlr.ast.expr_contextType", - "org.python.antlr.ast.boolopType", - "org.python.antlr.ast.unaryopType", - "org.python.antlr.ast.cmpopType", - "org.python.antlr.ast.operatorType"): - result = str(t) + if result in ("expr_contextType", + "boolopType", + "unaryopType", + "cmpopType", + "operatorType"): + result = t.name() else: result = result.split(".")[-1] if result.endswith("Type"): Modified: trunk/jython/Lib/test/test_class_jy.py =================================================================== --- trunk/jython/Lib/test/test_class_jy.py 2008-09-06 23:20:46 UTC (rev 5300) +++ trunk/jython/Lib/test/test_class_jy.py 2008-09-07 05:57:26 UTC (rev 5301) @@ -273,12 +273,29 @@ self.assert_(isinstance(retro, OldStyle)) +class JavaClassNamingTestCase(unittest.TestCase): + """ + Tests for PyJavaClass naming. + """ + + def test_java_class_name(self): + """ + The __name__ and __module__ attributes of Java classes should be set + according to the same convention that Python uses. + """ + from java.lang import String + self.assertEqual(String.__name__, "String") + self.assertEqual(String.__module__, "java.lang") + + + def test_main(): test_support.run_unittest(ClassGeneralTestCase, ClassNamelessModuleTestCase, BrokenNameTestCase, ClassLocalsTestCase, - IsDescendentTestCase) + IsDescendentTestCase, + JavaClassNamingTestCase) if __name__ == "__main__": Modified: trunk/jython/src/org/python/core/PyJavaClass.java =================================================================== --- trunk/jython/src/org/python/core/PyJavaClass.java 2008-09-06 23:20:46 UTC (rev 5300) +++ trunk/jython/src/org/python/core/PyJavaClass.java 2008-09-07 05:57:26 UTC (rev 5301) @@ -75,8 +75,30 @@ init(c); } - protected PyJavaClass(String name,PackageManager mgr) { - __name__ = name; + public String __module__; + /** + * Set the full name of this class. + */ + private void setName(String name) { + int dotIndex = name.lastIndexOf("."); + if (dotIndex == -1) { + __name__ = name; + __module__ = ""; + } else { + __name__ = name.substring(name.lastIndexOf(".")+1, name.length()); + __module__ = name.substring(0, name.lastIndexOf(".")); + } + } + + private String fullName() { + if (__module__ == "") + return __name__; + else + return __module__ + "." + __name__; + } + + protected PyJavaClass(String name, PackageManager mgr) { + setName(name); this.__mgr__ = mgr; } @@ -97,7 +119,7 @@ } private static final void initLazy(PyJavaClass jc) { - Class c = jc.__mgr__.findClass(null,jc.__name__,"lazy java class"); + Class c = jc.__mgr__.findClass(null,jc.fullName(),"lazy java class"); check_lazy_allowed(c); // xxx jc.init(c); tbl.putCanonical(jc.proxyClass,jc); @@ -209,7 +231,7 @@ private void init(Class c) { proxyClass = c; - __name__ = c.getName(); + setName(c.getName()); } /** @@ -761,6 +783,8 @@ } if (name == "__name__") return new PyString(__name__); + if (name == "__module__") + return new PyString(__module__); if (name == "__bases__") { if (__bases__ == null) initialize(); @@ -851,11 +875,11 @@ if (PyObject.class.isAssignableFrom(proxyClass)) { if (Modifier.isAbstract(proxyClass.getModifiers())) { throw Py.TypeError("can't instantiate abstract class ("+ - __name__+")"); + fullName()+")"); } if (__init__ == null) { throw Py.TypeError("no public constructors for "+ - __name__); + fullName()); } return __init__.make(args,keywords); } @@ -871,7 +895,19 @@ return super.__tojava__(c); } + public int __cmp__(PyObject other) { + if (!(other instanceof PyJavaClass)) { + return -2; + } + int c = fullName().compareTo(((PyJavaClass) other).fullName()); + return c < 0 ? -1 : c > 0 ? 1 : 0; + } + + public PyString __str__() { + return new PyString(fullName()); + } + public String toString() { - return "<jclass "+__name__+" "+Py.idstr(this)+">"; + return "<jclass "+fullName()+" "+Py.idstr(this)+">"; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-06 23:20:48
|
Revision: 5300 http://jython.svn.sourceforge.net/jython/?rev=5300&view=rev Author: fwierzbicki Date: 2008-09-06 23:20:46 +0000 (Sat, 06 Sep 2008) Log Message: ----------- Add alpha2 link and remove jeps directory. Modified Paths: -------------- trunk/website/Project/index.txt Removed Paths: ------------- trunk/website/jeps/ Modified: trunk/website/Project/index.txt =================================================================== --- trunk/website/Project/index.txt 2008-09-06 21:09:32 UTC (rev 5299) +++ trunk/website/Project/index.txt 2008-09-06 23:20:46 UTC (rev 5300) @@ -11,8 +11,12 @@ .. admonition:: Latest News - The Jython development team is proud to announce a new release: Jython 2.2.1! + The Jython development team is proud to announce a new alpha release: Jython 2.5a2! + * `Test the alpha <http://downloads.sourceforge.net/jython/jython_installer-2.5a2.jar>`__ + + For production use please continue to use Jython 2.2.1 + * `Download location`_ * `Installation instructions <installation.html>`__ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-06 21:09:35
|
Revision: 5299 http://jython.svn.sourceforge.net/jython/?rev=5299&view=rev Author: fwierzbicki Date: 2008-09-06 21:09:32 +0000 (Sat, 06 Sep 2008) Log Message: ----------- tagging alpha2 Added Paths: ----------- tags/Release_2_5alpha2/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-06 21:02:12
|
Revision: 5298 http://jython.svn.sourceforge.net/jython/?rev=5298&view=rev Author: fwierzbicki Date: 2008-09-06 21:02:09 +0000 (Sat, 06 Sep 2008) Log Message: ----------- Create a maint branch for 2.5. Added Paths: ----------- branches/Release_2_5maint/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-06 20:57:48
|
Revision: 5297 http://jython.svn.sourceforge.net/jython/?rev=5297&view=rev Author: fwierzbicki Date: 2008-09-06 20:57:46 +0000 (Sat, 06 Sep 2008) Log Message: ----------- Remove more leakage from asm branch into build.xml. Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2008-09-06 20:07:25 UTC (rev 5296) +++ trunk/jython/build.xml 2008-09-06 20:57:46 UTC (rev 5297) @@ -217,8 +217,8 @@ <property name="full-build" value="true" /> <!-- predefined main directory for checkout --> - <property name="svn.main.dir" value="branches" /> - <property name="svn.code.dir" value="asm" /> + <property name="svn.main.dir" value="trunk" /> + <property name="svn.code.dir" value="jython" /> <property name="svn.installer.dir" value="installer" /> <!-- properties work.dir and jython.base.dir are also definied in init, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |