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: <pj...@us...> - 2008-10-21 21:25:28
|
Revision: 5500 http://jython.svn.sourceforge.net/jython/?rev=5500&view=rev Author: pjenvey Date: 2008-10-21 21:25:21 +0000 (Tue, 21 Oct 2008) Log Message: ----------- fix passing a null node to the ParseException for bare except clauses that aren't the last clause, and match the error message to CPython Modified Paths: -------------- trunk/jython/src/org/python/compiler/CodeCompiler.java Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2008-10-21 20:02:03 UTC (rev 5499) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2008-10-21 21:25:21 UTC (rev 5500) @@ -1137,7 +1137,7 @@ } else { if (i != node.handlers.length-1) { throw new ParseException( - "bare except must be last except clause", handler.type); + "default 'except:' must be last", handler); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-10-21 20:02:06
|
Revision: 5499 http://jython.svn.sourceforge.net/jython/?rev=5499&view=rev Author: fwierzbicki Date: 2008-10-21 20:02:03 +0000 (Tue, 21 Oct 2008) Log Message: ----------- Allow error handling to be customized in the case of token mismatch calls during parsing. Modified Paths: -------------- trunk/jython/grammar/Python.g trunk/jython/src/org/python/antlr/ErrorHandler.java trunk/jython/src/org/python/antlr/FailFastHandler.java trunk/jython/src/org/python/antlr/ListErrorHandler.java Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2008-10-21 18:44:08 UTC (rev 5498) +++ trunk/jython/grammar/Python.g 2008-10-21 20:02:03 UTC (rev 5499) @@ -165,21 +165,19 @@ } protected void mismatch(IntStream input, int ttype, BitSet follow) throws RecognitionException { - if (errorHandler.isRecoverable()) { + if (errorHandler.mismatch(this, input, ttype, follow)) { super.mismatch(input, ttype, follow); - } else { - throw new MismatchedTokenException(ttype, input); } } protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) - throws RecognitionException - { - if (errorHandler.isRecoverable()) { - return super.recoverFromMismatchedToken(input, ttype, follow); + throws RecognitionException { + + Object o = errorHandler.recoverFromMismatchedToken(this, input, ttype, follow); + if (o != null) { + return o; } - mismatch(input, ttype, follow); - return null; + return super.recoverFromMismatchedToken(input, ttype, follow); } } Modified: trunk/jython/src/org/python/antlr/ErrorHandler.java =================================================================== --- trunk/jython/src/org/python/antlr/ErrorHandler.java 2008-10-21 18:44:08 UTC (rev 5498) +++ trunk/jython/src/org/python/antlr/ErrorHandler.java 2008-10-21 20:02:03 UTC (rev 5499) @@ -1,6 +1,7 @@ package org.python.antlr; import org.antlr.runtime.BaseRecognizer; +import org.antlr.runtime.BitSet; import org.antlr.runtime.IntStream; import org.antlr.runtime.Lexer; import org.antlr.runtime.RecognitionException; @@ -13,7 +14,19 @@ void reportError(BaseRecognizer br, RecognitionException re); void recover(BaseRecognizer br, IntStream input, RecognitionException re); void recover(Lexer lex, RecognitionException re); - boolean isRecoverable(); + + /** + * @return True if the caller should handle the mismatch + */ + boolean mismatch(BaseRecognizer br, IntStream input, int ttype, BitSet follow) + throws RecognitionException; + + /** + * @return null if the caller should handle the mismatch + */ + Object recoverFromMismatchedToken(BaseRecognizer br, IntStream input, int ttype, BitSet follow) + throws RecognitionException; + //exprType, modType, sliceType, stmtType exprType errorExpr(PythonTree t); modType errorMod(PythonTree t); Modified: trunk/jython/src/org/python/antlr/FailFastHandler.java =================================================================== --- trunk/jython/src/org/python/antlr/FailFastHandler.java 2008-10-21 18:44:08 UTC (rev 5498) +++ trunk/jython/src/org/python/antlr/FailFastHandler.java 2008-10-21 20:02:03 UTC (rev 5499) @@ -1,8 +1,10 @@ package org.python.antlr; import org.antlr.runtime.BaseRecognizer; +import org.antlr.runtime.BitSet; import org.antlr.runtime.IntStream; import org.antlr.runtime.Lexer; +import org.antlr.runtime.MismatchedTokenException; import org.antlr.runtime.RecognitionException; import org.python.antlr.ast.ErrorMod; import org.python.antlr.ast.exprType; @@ -27,10 +29,17 @@ throw new ParseException(message(br,re), re); } - public boolean isRecoverable() { - return false; + public boolean mismatch(BaseRecognizer br, IntStream input, int ttype, BitSet follow) + throws RecognitionException { + + throw new MismatchedTokenException(ttype, input); } + public Object recoverFromMismatchedToken(BaseRecognizer br, IntStream input, int ttype, + BitSet follow) throws RecognitionException { + throw new MismatchedTokenException(ttype, input); + } + public exprType errorExpr(PythonTree t) { throw new ParseException("Bad Expr Node", t); } Modified: trunk/jython/src/org/python/antlr/ListErrorHandler.java =================================================================== --- trunk/jython/src/org/python/antlr/ListErrorHandler.java 2008-10-21 18:44:08 UTC (rev 5498) +++ trunk/jython/src/org/python/antlr/ListErrorHandler.java 2008-10-21 20:02:03 UTC (rev 5499) @@ -1,6 +1,7 @@ package org.python.antlr; import org.antlr.runtime.BaseRecognizer; +import org.antlr.runtime.BitSet; import org.antlr.runtime.IntStream; import org.antlr.runtime.Lexer; import org.antlr.runtime.RecognitionException; @@ -27,10 +28,14 @@ br.recover(input, re); } - public boolean isRecoverable() { + public boolean mismatch(BaseRecognizer br, IntStream input, int ttype, BitSet follow) { return true; } + public Object recoverFromMismatchedToken(BaseRecognizer br, IntStream input, int ttype, BitSet follow) { + return null; + } + public exprType errorExpr(PythonTree t) { return new ErrorExpr(t); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-10-21 18:44:14
|
Revision: 5498 http://jython.svn.sourceforge.net/jython/?rev=5498&view=rev Author: pjenvey Date: 2008-10-21 18:44:08 +0000 (Tue, 21 Oct 2008) Log Message: ----------- IOErrors are expected for unsupported file operations, instead of TypeErrors Modified Paths: -------------- trunk/jython/Lib/test/test_java_integration.py trunk/jython/src/org/python/core/io/IOBase.java Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2008-10-21 10:53:16 UTC (rev 5497) +++ trunk/jython/Lib/test/test_java_integration.py 2008-10-21 18:44:08 UTC (rev 5498) @@ -154,6 +154,10 @@ from java.io import FileInputStream, FileNotFoundException self.assertRaises(FileNotFoundException, FileInputStream, "garbage") + def test_unsupported(self): + fp = open(System.out) + self.assertRaises(IOError, fp.tell) + class VectorTest(unittest.TestCase): def test_looping(self): Modified: trunk/jython/src/org/python/core/io/IOBase.java =================================================================== --- trunk/jython/src/org/python/core/io/IOBase.java 2008-10-21 10:53:16 UTC (rev 5497) +++ trunk/jython/src/org/python/core/io/IOBase.java 2008-10-21 18:44:08 UTC (rev 5498) @@ -210,6 +210,6 @@ protected void unsupported(String methodName) { String qualifiedName = getClass().getName(); String className = qualifiedName.substring(qualifiedName.lastIndexOf('.') + 1); - throw Py.TypeError(String.format("%s.%s() not supported", className, methodName)); + throw Py.IOError(String.format("%s.%s() not supported", className, methodName)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2008-10-21 10:53:35
|
Revision: 5497 http://jython.svn.sourceforge.net/jython/?rev=5497&view=rev Author: thobes Date: 2008-10-21 10:53:16 +0000 (Tue, 21 Oct 2008) Log Message: ----------- Merged revisions 5287-5295,5297,5301-5305,5307-5308,5313-5317,5320-5321,5323-5325,5327-5329,5333,5339-5444,5446-5447,5452-5460,5462-5480,5482-5495 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython ........ r5287 | fwierzbicki | 2008-09-03 17:24:20 +0200 (Wed, 03 Sep 2008) | 3 lines Small cleanup of compiler package. Mainly remove unused imports and rename local vars that shadow member vars. ........ r5288 | fwierzbicki | 2008-09-04 18:57:30 +0200 (Thu, 04 Sep 2008) | 3 lines Fix for some offset problems -- the biggest one being dedents now take on the offset values of the previous token. ........ r5289 | fwierzbicki | 2008-09-05 05:36:04 +0200 (Fri, 05 Sep 2008) | 3 lines Adjustment to offset fix. Overthought the offsets for simple dedents. ........ r5290 | zyasoft | 2008-09-05 18:21:55 +0200 (Fri, 05 Sep 2008) | 4 lines PySystemState.warnoptions was not initialized before adding to it in the processing of the -W option. ........ r5291 | fwierzbicki | 2008-09-05 18:30:36 +0200 (Fri, 05 Sep 2008) | 2 lines Broke test_traceback.py in my last commit. This fixes it again. ........ r5292 | fwierzbicki | 2008-09-06 06:28:11 +0200 (Sat, 06 Sep 2008) | 2 lines Some tuning of node col and line positions to align better with CPython. ........ r5293 | fwierzbicki | 2008-09-06 20:31:14 +0200 (Sat, 06 Sep 2008) | 2 lines Switch back installer25 -> installer. Leaked in from asm branch. ........ r5294 | fwierzbicki | 2008-09-06 20:58:02 +0200 (Sat, 06 Sep 2008) | 2 lines increment version. ........ r5295 | fwierzbicki | 2008-09-06 21:34:07 +0200 (Sat, 06 Sep 2008) | 2 lines Update README. ........ r5297 | fwierzbicki | 2008-09-06 22:57:46 +0200 (Sat, 06 Sep 2008) | 2 lines Remove more leakage from asm branch into build.xml. ........ r5301 | fwierzbicki | 2008-09-07 07:57:26 +0200 (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 16:41:41 +0200 (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 19:48:28 +0200 (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 20:42:57 +0200 (Tue, 09 Sep 2008) | 2 lines Fix some offset problems in DEDENT, INDENT, and EOF. ........ r5305 | fwierzbicki | 2008-09-09 21:06:17 +0200 (Tue, 09 Sep 2008) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib@66318 ........ r5307 | fwierzbicki | 2008-09-09 23:15:54 +0200 (Tue, 09 Sep 2008) | 2 lines Disable refcount test with is_jython check. ........ r5308 | otmarhumbel | 2008-09-10 00:34:55 +0200 (Wed, 10 Sep 2008) | 1 line applied leosoto's patch from http://bugs.jython.org/issue1077 to avoid duplicate entries in jython-complete.jar ........ r5313 | fwierzbicki | 2008-09-10 20:36:16 +0200 (Wed, 10 Sep 2008) | 3 lines Make it possible to get error nodes into the spots that are now casting to exprType. ........ r5314 | otmarhumbel | 2008-09-11 00:45:07 +0200 (Thu, 11 Sep 2008) | 3 lines 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 ........ r5315 | otmarhumbel | 2008-09-11 01:06:04 +0200 (Thu, 11 Sep 2008) | 4 lines 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 ........ r5316 | fwierzbicki | 2008-09-11 02:37:30 +0200 (Thu, 11 Sep 2008) | 2 lines update readme for Jython 2.5a3. ........ r5317 | fwierzbicki | 2008-09-11 02:39:43 +0200 (Thu, 11 Sep 2008) | 2 lines Change defaults for alpha 3. ........ r5320 | fwierzbicki | 2008-09-11 21:48:35 +0200 (Thu, 11 Sep 2008) | 3 lines Transform if/elif/else into the correct If nodes in the grammar file instead of as a code post-processing step. ........ r5321 | fwierzbicki | 2008-09-11 22:18:43 +0200 (Thu, 11 Sep 2008) | 2 lines Allow the possibility of using error nodes for bad stmtType. ........ r5323 | leosoto | 2008-09-13 19:04:58 +0200 (Sat, 13 Sep 2008) | 1 line Test for the 'feature' described on #1089: cStringIO.StringIO.read always returns string objects ........ r5324 | amak | 2008-09-13 20:09:58 +0200 (Sat, 13 Sep 2008) | 11 lines Checking in fixes for 3 bugs http://bugs.jython.org/issue1119 - socket module has no attribute SO_ERROR http://bugs.jython.org/issue1120 - invalid socket shutdown gives AssertionError, should be "transport endpoint not connected" socket.error http://bugs.jython.org/issue1121 - listening socket shutdown expects the wrong kind of socket ........ r5325 | amak | 2008-09-13 20:31:07 +0200 (Sat, 13 Sep 2008) | 5 lines Change of mind on behaviour when shutting down server sockets. Instead to raising an exception, best to let the failure pass silently, as cpython does. http://bugs.jython.org/issue1121 ........ r5327 | zyasoft | 2008-09-13 21:02:55 +0200 (Sat, 13 Sep 2008) | 2 lines Tests that __module__ is available during class definition time, for #1022 ........ r5328 | zyasoft | 2008-09-14 02:08:28 +0200 (Sun, 14 Sep 2008) | 4 lines Adds tests: test_copy, test_profilehooks, test_random, test_syntax, test_trace that should be reasonable for Jython (possibly with modifications) Provides coverage for #1738411 ........ r5329 | pjenvey | 2008-09-14 02:27:02 +0200 (Sun, 14 Sep 2008) | 1 line small cleanup ........ r5333 | fwierzbicki | 2008-09-16 01:57:05 +0200 (Tue, 16 Sep 2008) | 2 lines make accept and traverse no-ops for error nodes. ........ r5339 | fwierzbicki | 2008-09-18 21:07:35 +0200 (Thu, 18 Sep 2008) | 3 lines Fixed another eof/whitespace parsing issue from Django. Turned all of these problems into a new test: test_eof_jy.py. ........ r5340 | fwierzbicki | 2008-09-18 21:37:19 +0200 (Thu, 18 Sep 2008) | 3 lines Unicode ast node is a kludge from long ago whose time has passed. I forgot to remove it when I unified str node handling in the parser. ........ r5341 | leosoto | 2008-09-20 04:08:34 +0200 (Sat, 20 Sep 2008) | 1 line PyType now exposes __repr__ and __str__ as documented on <http://wiki.python.org/jython/JythonDeveloperGuide/ImplementingStrAndRepr>. This fixes #1131 ........ r5342 | leosoto | 2008-09-21 02:20:23 +0200 (Sun, 21 Sep 2008) | 1 line importing test_support from the test package on test_exceptions.py ........ r5343 | pjenvey | 2008-09-24 21:44:25 +0200 (Wed, 24 Sep 2008) | 4 lines it's more correct for StdoutWrapper to write the object being printed to the file instead of __str__'ing it refs #1130 ........ r5344 | pjenvey | 2008-09-24 21:56:28 +0200 (Wed, 24 Sep 2008) | 1 line revert r5343, it's broken ........ r5345 | fwierzbicki | 2008-09-24 23:05:39 +0200 (Wed, 24 Sep 2008) | 4 lines Switched PythonPartial.g from being a "grammar" to being a "parser grammar", plus some additional related cleanup. This fixes all of the missing Token warnings. Thanks to Terrance Parr for suggesting this fix. ........ r5346 | thobes | 2008-09-25 00:12:23 +0200 (Thu, 25 Sep 2008) | 4 lines Fixed the bug of the __exit__ method not being invoked on the outer context manager in the case of nested with statements. The problem was that the exception handlers were not properly sorted. ........ r5347 | thobes | 2008-09-25 20:52:30 +0200 (Thu, 25 Sep 2008) | 7 lines Fix of the bug with "def f(): lambda x=(yield): 1". The problem was that the order of instructions were such that there was elements on the stack before the yield-point that does not get restored. I also found another problem in that the types for local variables in CodeCompiler are not proper java types, this is in error in nearly all places, and needs to be fixed in a later commit. ........ r5348 | pjenvey | 2008-09-25 23:12:28 +0200 (Thu, 25 Sep 2008) | 5 lines bump tarfile from 2.5.1 to 2.5.2, from: http://svn.python.org/projects/python/branches/release25-maint/Lib tarfile.py@60730 test/test_tarfile.py@60730 ........ r5349 | pjenvey | 2008-09-25 23:16:30 +0200 (Thu, 25 Sep 2008) | 6 lines reapply previous tarfile modifications: o don't assume a reference counting GC o ensure all file handles are closed to avoid os.remove problems on windows o always use the tempdir, even when testtar is a relative path (it is when ran via the regrtest) ........ r5350 | fwierzbicki | 2008-09-26 16:41:55 +0200 (Fri, 26 Sep 2008) | 3 lines Correct this for new __class__.__name__ package truncating behavior of Java classes. ........ r5351 | thobes | 2008-09-26 17:37:19 +0200 (Fri, 26 Sep 2008) | 4 lines Fix to allow the yield statement to apear in the first iterator of a generator expression. This exposes another problem where the stack state is not persisted from yielding to resuming. ........ r5352 | fwierzbicki | 2008-09-26 19:01:58 +0200 (Fri, 26 Sep 2008) | 3 lines Fixes an infinite loop that occurs when there is an unterminated triple string and ListErrorHandler is being used. ........ r5353 | fwierzbicki | 2008-10-01 04:01:33 +0200 (Wed, 01 Okt 2008) | 3 lines Added castSlice and castSlices to allow optional error nodes for sliceType. Also renamed makeExpr(s) and makeStmt(s) to castExpr(s) and castStmt(s). ........ r5354 | pjenvey | 2008-10-02 02:13:21 +0200 (Thu, 02 Okt 2008) | 2 lines remove more remnants of org.python.antlr.ast.Unicode ........ r5355 | pjenvey | 2008-10-02 02:16:29 +0200 (Thu, 02 Okt 2008) | 1 line whitespace ........ r5356 | pjenvey | 2008-10-02 04:31:03 +0200 (Thu, 02 Okt 2008) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_asynchat.py@46906 ........ r5357 | pjenvey | 2008-10-05 02:00:24 +0200 (Sun, 05 Okt 2008) | 3 lines avoid test_asynchat on BSD where it deadlocks refs #1064 ........ r5358 | pjenvey | 2008-10-05 02:01:52 +0200 (Sun, 05 Okt 2008) | 1 line fix mislabeled names ........ r5359 | zyasoft | 2008-10-06 05:02:29 +0200 (Mon, 06 Okt 2008) | 3 lines From http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_random.py@53510 ........ r5360 | zyasoft | 2008-10-06 05:12:34 +0200 (Mon, 06 Okt 2008) | 6 lines Removed older version of random.py in favor of CPythonLib's; added _random.getrandbits (in PyRandom); modified test_random so that it doesn't test implementation specific aspects of the random generator, since we actually use java.util.Random, not the Mersenne Twister. ........ r5361 | zyasoft | 2008-10-06 20:57:58 +0200 (Mon, 06 Okt 2008) | 6 lines Fixed test_quopri by encoding space or tab before newline and resetting the column count upon a newline Fixed #1144 so that -mMODULE works and remaining args are passed in sys.argv ........ r5362 | zyasoft | 2008-10-06 22:42:04 +0200 (Mon, 06 Okt 2008) | 3 lines From http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_trace.py@60582 ........ r5363 | zyasoft | 2008-10-06 23:48:03 +0200 (Mon, 06 Okt 2008) | 6 lines Removed test cases not applicable to Jython. Although it's not possible to implement jump when compiled to Java bytecode, it's possible that we can better align our trace with what is done in CPython, so this should be revisited at some point. ........ r5364 | zyasoft | 2008-10-07 00:00:46 +0200 (Tue, 07 Okt 2008) | 3 lines From http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_profilehooks.py@35570 ........ r5365 | zyasoft | 2008-10-07 00:08:13 +0200 (Tue, 07 Okt 2008) | 5 lines Similar mass removal of tests as in test_trace, these all are related to some fundamental differences in our VM, especially around exception handling. ........ r5366 | pjenvey | 2008-10-10 01:23:05 +0200 (Fri, 10 Okt 2008) | 3 lines fix lambdas within decorator args causing an NPE. we weren't initializing their scopes ........ r5367 | fwierzbicki | 2008-10-10 20:12:58 +0200 (Fri, 10 Okt 2008) | 2 lines Cleaning up dead code. ........ r5368 | zyasoft | 2008-10-11 04:24:42 +0200 (Sat, 11 Okt 2008) | 3 lines From http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_copy.py@42573 ........ r5369 | zyasoft | 2008-10-11 04:38:55 +0200 (Sat, 11 Okt 2008) | 9 lines Make "extended" builtin functions in __builtin__ (that is, functions like max which use a class like MaxFunction for their definition) copyable by copy.copy and return the correct type. This fixes test_copy, along with enabling reflexive structures to be compared, since we don't prohibit or otherwise detect them in the copying anyway. ........ r5370 | zyasoft | 2008-10-11 05:37:39 +0200 (Sat, 11 Okt 2008) | 2 lines Patch from #1075, thanks Matt Boersma! ........ r5371 | pjenvey | 2008-10-11 07:08:23 +0200 (Sat, 11 Okt 2008) | 3 lines disable test_compiler as we don't intend to support the parser module compiler relies on, with _ast being the way forward ........ r5372 | pjenvey | 2008-10-11 08:42:35 +0200 (Sat, 11 Okt 2008) | 3 lines fix solid_base potentially resolving the wrong type when called before the mro was initialized. caused best_base to blowup with a TypeError ........ r5373 | fwierzbicki | 2008-10-11 22:54:47 +0200 (Sat, 11 Okt 2008) | 3 lines Throw a Python exception for two internal compiler errors that where just printing a less useful error message and going on to an NPE. ........ r5374 | fwierzbicki | 2008-10-11 23:29:29 +0200 (Sat, 11 Okt 2008) | 11 lines A very basic start to supporting pep 328 style relative imports like from . import foo This patch just passes the "level" (that is number of dots) information from the compile to the import machinary without actually using it, and forbids from . import * As Python 2.5 does. ........ r5375 | pjenvey | 2008-10-12 01:16:54 +0200 (Sun, 12 Okt 2008) | 2 lines fix unicodedata.lookup to return unicode instead of the codepoint int ........ r5376 | zyasoft | 2008-10-12 02:18:38 +0200 (Sun, 12 Okt 2008) | 3 lines From http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_struct.py@60892 ........ r5377 | zyasoft | 2008-10-12 02:24:30 +0200 (Sun, 12 Okt 2008) | 2 lines Implemented struct.Struct as well as other updates in the struct module for 2.5 ........ r5378 | zyasoft | 2008-10-12 02:25:07 +0200 (Sun, 12 Okt 2008) | 2 lines Missing module for previous commit! ........ r5379 | fwierzbicki | 2008-10-12 18:28:15 +0200 (Sun, 12 Okt 2008) | 7 lines More groundwork for absolute_import. Passing level info into most of the places it needs to go, also now sending the correct level information when "from __future__ import absolute_import" is issued. Added a constant in imp.java DEFAULT_LEVEL, so that it can be changed in one place when absolute import becomes the default behavior. ........ r5380 | pjenvey | 2008-10-12 22:10:04 +0200 (Sun, 12 Okt 2008) | 5 lines fix bad bytecode generated for: a[[b for b, c in d]] = e the store was losing track of the value (e) here because the list comp/tuple unpack combo overwrote where e's location was held ........ r5381 | pjenvey | 2008-10-13 00:18:06 +0200 (Mon, 13 Okt 2008) | 2 lines better unhashable TypeError messages ........ r5382 | pjenvey | 2008-10-13 00:37:53 +0200 (Mon, 13 Okt 2008) | 2 lines update the deriveds for better unhashable TypeError messages ........ r5383 | pjenvey | 2008-10-13 01:00:34 +0200 (Mon, 13 Okt 2008) | 1 line fix the renamed _collections ........ r5384 | fwierzbicki | 2008-10-13 19:19:47 +0200 (Mon, 13 Okt 2008) | 2 lines Fixed issue http://bugs.jython.org/issue1111: keyword arguments not supported on __import__ ........ r5385 | fwierzbicki | 2008-10-13 19:31:05 +0200 (Mon, 13 Okt 2008) | 4 lines disable test_transformer for the same reason we disabled test_compiler: we don't intend to support the parser module compiler relies on, with _ast being the way forward. transformer.py is in the same area of code. ........ r5386 | fwierzbicki | 2008-10-13 20:50:06 +0200 (Mon, 13 Okt 2008) | 7 lines Fixed "expected skips" that wheren't actually being skipped. Also added test_peepholer and test_profile to expected failures since these are platform specific tests. This is a work around, we should (most likely) go back and force these expected failures to skip in Jython, but I want to do that in one future sweep. ........ r5387 | fwierzbicki | 2008-10-13 21:41:45 +0200 (Mon, 13 Okt 2008) | 3 lines from http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_with.py@66619 ........ r5388 | fwierzbicki | 2008-10-13 22:38:36 +0200 (Mon, 13 Okt 2008) | 4 lines Disabling tests of "as" and "with" semi-keyword status, for now it's too hard to get antlr to treat them as almost-keywords. I want to revisit, but this is a low priority compared to other problems. ........ r5389 | cgroves | 2008-10-14 03:47:30 +0200 (Tue, 14 Okt 2008) | 1 line Jarjar if antlr changed more recently than the jarjar'd jar. Jar. ........ r5390 | leosoto | 2008-10-14 05:20:10 +0200 (Tue, 14 Okt 2008) | 1 line Now String is mapped to PyUnicode on ClassicPyObjectAdapter (instead of mapping it to PyString). Thus, for APIs which really need to return bytestrings (such as PyFile) we now have to explicitely declare the return type as PyString (and on code written in Python, use StringUtil.asPyString(String)). Fixes #1128 ........ r5391 | fwierzbicki | 2008-10-14 18:43:46 +0200 (Tue, 14 Okt 2008) | 4 lines Fix or skips for most remaining problems in test_syntax.py. All remaining problems are due to the lack of enforcement on continuations not being permitted in finally. ........ r5392 | fwierzbicki | 2008-10-14 21:28:28 +0200 (Tue, 14 Okt 2008) | 4 lines Added inFinally parameter to suite rule, and a dynamically scoped parameter continueIllegal to support disallowing continue in a finally clause. This fixes test_syntax. ........ r5393 | pjenvey | 2008-10-15 01:08:45 +0200 (Wed, 15 Okt 2008) | 5 lines o fix the socket hostname functions returning unicode hostnames instead of strs. was causing test_wsgiref to fail on environments where socket.getfqdn('localhost') != 'localhost' o fix getaddrinfo default family and handling of bad familys ........ r5394 | pjenvey | 2008-10-15 02:46:02 +0200 (Wed, 15 Okt 2008) | 2 lines fix solid_base considering slotted objects with a __dict__ as solid ........ r5395 | cgroves | 2008-10-15 06:42:15 +0200 (Wed, 15 Okt 2008) | 8 lines Remove build/exposed from the classpath. Having it in there meant any source navigation like F3 or Open Type would go to the exposed version rather than the source version that you were really after. Not having it in there means you need to add the exposed dir to the classpath of any run configurations in Eclipse, but that felt like a lesser evil than my smiting my keyboard in frustration every time Eclipse opened the wrong file. ........ r5396 | otmarhumbel | 2008-10-15 07:35:53 +0200 (Wed, 15 Okt 2008) | 1 line fixed typo: _JAVA_HOME has to be JAVA_HOME ........ r5397 | otmarhumbel | 2008-10-15 10:10:37 +0200 (Wed, 15 Okt 2008) | 7 lines safely test if JAVA_HOME or JYTHON_HOME is set we can now handle both quoted and unquoted settings like: JAVA_HOME=C:\Program Files\Java\jdk1.6.0_07 JAVA_HOME="C:\Program Files\Java\jdk1.6.0_07" this should fix issue #1125 ........ r5398 | otmarhumbel | 2008-10-15 17:56:58 +0200 (Wed, 15 Okt 2008) | 1 line applied lsoto's PyString change (revision 5390) to this handler as well ........ r5399 | fwierzbicki | 2008-10-15 19:06:58 +0200 (Wed, 15 Okt 2008) | 6 lines New dotted and absolute import support. I have local tests, but have not figured out how to integrate them into the regression tests. Examining the tests in CPython does not appear to give much guidance here, the testing of these features looks pretty thin (mainly they test features around __package__ which is new in 2.6). Maybe I just haven't found the relevant tests? ........ r5400 | fwierzbicki | 2008-10-15 22:10:46 +0200 (Wed, 15 Okt 2008) | 2 lines ? was replaced by <module> in info. ........ r5401 | fwierzbicki | 2008-10-15 22:16:53 +0200 (Wed, 15 Okt 2008) | 5 lines Guard the Java-specific top imports with an is_jython. This way some of the bugtests can run in pure python to make it easier to tilt at this windmill: http://code.google.com/p/google-highly-open-participation-psf/source/browse/trunk/submissions/jython-tests-26-50.txt?r=424 Windmill summary: Turn all bugtests into real unit tests or kill. ........ r5402 | fwierzbicki | 2008-10-15 22:22:02 +0200 (Wed, 15 Okt 2008) | 2 lines Move bugtests/test076.py into regrtest. ........ r5403 | fwierzbicki | 2008-10-15 22:23:35 +0200 (Wed, 15 Okt 2008) | 2 lines test077.py is well tested in our current unit tests. ........ r5404 | fwierzbicki | 2008-10-15 22:35:18 +0200 (Wed, 15 Okt 2008) | 2 lines test078.py is outdated. ........ r5405 | fwierzbicki | 2008-10-15 22:37:54 +0200 (Wed, 15 Okt 2008) | 2 lines "find" is well tested and doesn't need this extra test. ........ r5406 | fwierzbicki | 2008-10-15 22:41:18 +0200 (Wed, 15 Okt 2008) | 3 lines test_pkgimport.py already does a reasonable job of checking multiple imports of the same .py file. ........ r5407 | fwierzbicki | 2008-10-15 22:42:47 +0200 (Wed, 15 Okt 2008) | 2 lines cleanup dead code. ........ r5408 | fwierzbicki | 2008-10-15 22:44:08 +0200 (Wed, 15 Okt 2008) | 2 lines This basic re functionality is well tested in our existing unit tests. ........ r5409 | fwierzbicki | 2008-10-15 22:52:30 +0200 (Wed, 15 Okt 2008) | 4 lines test089.py looks like it is very confused :) Maybe string.replace changed oh so long ago? /me shrugs and deletes. ........ r5410 | fwierzbicki | 2008-10-15 22:55:46 +0200 (Wed, 15 Okt 2008) | 6 lines Comment at the top Does not work, will never work. Wow. Deleted. ........ r5411 | fwierzbicki | 2008-10-16 03:48:49 +0200 (Thu, 16 Okt 2008) | 2 lines another "will never work" test. Deleted. ........ r5412 | fwierzbicki | 2008-10-16 03:53:07 +0200 (Thu, 16 Okt 2008) | 3 lines Just tests the existance of a __name__ and __doc__ for the exceptions module. Not enough of a test to preserve. ........ r5413 | fwierzbicki | 2008-10-16 03:53:49 +0200 (Thu, 16 Okt 2008) | 2 lines deleting completely empty test. ........ r5414 | fwierzbicki | 2008-10-16 04:21:51 +0200 (Thu, 16 Okt 2008) | 2 lines Moved unique id test to test_jy_internals ........ r5415 | fwierzbicki | 2008-10-16 04:56:10 +0200 (Thu, 16 Okt 2008) | 2 lines First get test102.py working again... ........ r5416 | fwierzbicki | 2008-10-16 05:11:28 +0200 (Thu, 16 Okt 2008) | 2 lines test102 moved to test_jy_internals.py ........ r5417 | fwierzbicki | 2008-10-16 05:14:39 +0200 (Thu, 16 Okt 2008) | 2 lines Another empty test. ........ r5418 | fwierzbicki | 2008-10-16 05:15:27 +0200 (Thu, 16 Okt 2008) | 2 lines Another "does not work" ........ r5419 | pjenvey | 2008-10-16 05:28:52 +0200 (Thu, 16 Okt 2008) | 2 lines another unicode/str regression: co_name and co_filename should be a str ........ r5420 | pjenvey | 2008-10-16 08:38:43 +0200 (Thu, 16 Okt 2008) | 3 lines fix os.access not handling multiple modes, and make its X_OK work via jna-posix's stat ........ r5421 | fwierzbicki | 2008-10-16 14:07:24 +0200 (Thu, 16 Okt 2008) | 3 lines Move essential part of test106 to test_jy_compile.py (bare return not permitted in exec). ........ r5422 | fwierzbicki | 2008-10-16 14:15:26 +0200 (Thu, 16 Okt 2008) | 2 lines First make test107 pass in both python and jython ........ r5423 | fwierzbicki | 2008-10-16 14:42:06 +0200 (Thu, 16 Okt 2008) | 2 lines move test107 to test_jy_internals.py ........ r5424 | fwierzbicki | 2008-10-16 16:26:23 +0200 (Thu, 16 Okt 2008) | 2 lines Moved test108 to test_dict_jy ........ r5425 | fwierzbicki | 2008-10-16 16:27:55 +0200 (Thu, 16 Okt 2008) | 2 lines This basic functionality is well tested. ........ r5426 | fwierzbicki | 2008-10-16 16:29:48 +0200 (Thu, 16 Okt 2008) | 2 lines Basic dict functionality that is well tested in the unit tests. ........ r5427 | fwierzbicki | 2008-10-16 16:31:14 +0200 (Thu, 16 Okt 2008) | 3 lines Pretty much just a test for lists being disallowed as a key which is already in the unit tests. ........ r5428 | fwierzbicki | 2008-10-16 16:33:33 +0200 (Thu, 16 Okt 2008) | 2 lines Basic slice ops that are already well tested. ........ r5429 | fwierzbicki | 2008-10-16 16:34:25 +0200 (Thu, 16 Okt 2008) | 2 lines This test doesn't make much sense. ........ r5430 | fwierzbicki | 2008-10-16 16:36:02 +0200 (Thu, 16 Okt 2008) | 2 lines basic test of int subclasses which is well covered by current tests. ........ r5431 | fwierzbicki | 2008-10-16 18:13:52 +0200 (Thu, 16 Okt 2008) | 2 lines Leftover for long-gone test049. ........ r5432 | fwierzbicki | 2008-10-16 18:18:04 +0200 (Thu, 16 Okt 2008) | 2 lines move test124 to test_jy_internals. ........ r5433 | pjenvey | 2008-10-16 18:54:06 +0200 (Thu, 16 Okt 2008) | 1 line typo ........ r5434 | fwierzbicki | 2008-10-16 19:48:03 +0200 (Thu, 16 Okt 2008) | 3 lines The reload builtin is tested in a number of places in the unit tests, so this basic test of it can be deleted. ........ r5435 | fwierzbicki | 2008-10-16 19:48:56 +0200 (Thu, 16 Okt 2008) | 2 lines Very basic test of assert that is no longer needed as assert is well tested. ........ r5436 | fwierzbicki | 2008-10-16 19:50:37 +0200 (Thu, 16 Okt 2008) | 2 lines This test is already covered by a test in test_jy_internals. ........ r5437 | fwierzbicki | 2008-10-16 19:51:59 +0200 (Thu, 16 Okt 2008) | 2 lines Covered in test_jy_internals already. ........ r5438 | fwierzbicki | 2008-10-16 20:56:04 +0200 (Thu, 16 Okt 2008) | 2 lines moved test130 to test_cmp_jy. ........ r5439 | fwierzbicki | 2008-10-16 20:58:39 +0200 (Thu, 16 Okt 2008) | 2 lines This is well tested in test_hexoct.py ........ r5440 | fwierzbicki | 2008-10-16 22:19:50 +0200 (Thu, 16 Okt 2008) | 2 lines moved test131 into test_java_integration ........ r5441 | fwierzbicki | 2008-10-16 22:22:15 +0200 (Thu, 16 Okt 2008) | 2 lines test_glob thoroughly tests glob. ........ r5442 | fwierzbicki | 2008-10-16 22:24:04 +0200 (Thu, 16 Okt 2008) | 3 lines This really just tests that copy.copy exists. We run the real test_copy and so have no need for this test. ........ r5443 | fwierzbicki | 2008-10-16 22:32:40 +0200 (Thu, 16 Okt 2008) | 2 lines moved test136 to test_java_integration.py ........ r5444 | fwierzbicki | 2008-10-16 22:34:32 +0200 (Thu, 16 Okt 2008) | 2 lines better name for test method. ........ r5446 | cgroves | 2008-10-16 22:59:53 +0200 (Thu, 16 Okt 2008) | 9 lines Use assertRaises instead of try: code except ExpectedException: pass else: self.fail ........ r5447 | fwierzbicki | 2008-10-16 23:15:59 +0200 (Thu, 16 Okt 2008) | 3 lines put in null guard for cflags call. cflags can definitely be null at this point in the code. ........ r5452 | pjenvey | 2008-10-17 02:04:42 +0200 (Fri, 17 Okt 2008) | 2 lines minor xrange optimization: use the small int cache ........ r5453 | cgroves | 2008-10-17 09:06:39 +0200 (Fri, 17 Okt 2008) | 1 line A couple slices from Occam's razor, and speedups for items and keys by making arrays for PyList directly instead of making Lists and letting PyList turn them into arrays ........ r5454 | thobes | 2008-10-17 20:15:50 +0200 (Fri, 17 Okt 2008) | 3 lines Modifying the generated bytecode so that yield as an expression does not empty the stack. ........ r5455 | thobes | 2008-10-17 21:28:20 +0200 (Fri, 17 Okt 2008) | 2 lines Removed some erronious code in visitYield. ........ r5456 | thobes | 2008-10-17 22:46:47 +0200 (Fri, 17 Okt 2008) | 4 lines Improved the scope analysis for generator expressions. Also fixed a bug in my recent commit where the fix for yield as an expression accidentially reordered the value to be yielded on the stack. ........ r5457 | thobes | 2008-10-17 23:21:36 +0200 (Fri, 17 Okt 2008) | 4 lines Added a check for return and yield in the same scope in ScopesCompiler, There are cases that can be missed in CodeCompiler due to dead code elimination, this gets around that. ........ r5458 | pjenvey | 2008-10-18 01:55:52 +0200 (Sat, 18 Okt 2008) | 3 lines allow more heap for the regrtest to avoid the OutOfMemory errors. we don't seem to actually be leaking -- we just have more test modules ........ r5459 | pjenvey | 2008-10-18 01:56:07 +0200 (Sat, 18 Okt 2008) | 2 lines remove stray print statement that was preventing this from passing ........ r5460 | pjenvey | 2008-10-18 03:58:29 +0200 (Sat, 18 Okt 2008) | 4 lines store the symbol name info in a LinkedHashMap to maintain the order they're encountered in. fixes test_code technically this should bump the bytecode magic but it's not that important ........ r5462 | pjenvey | 2008-10-18 22:23:01 +0200 (Sat, 18 Okt 2008) | 3 lines fix os.access to never raise an exception with a valid mode, which I broke in r5420 ........ r5463 | pjenvey | 2008-10-19 02:01:20 +0200 (Sun, 19 Okt 2008) | 7 lines fix forgetting to free the var/starargs of Calls, which produced bad byte for: def gen(): if True: # or b(**c) a = b(*c) yield d ........ r5464 | cgroves | 2008-10-19 05:04:44 +0200 (Sun, 19 Okt 2008) | 1 line Some formatting and cleanup ........ r5465 | cgroves | 2008-10-19 07:14:22 +0200 (Sun, 19 Okt 2008) | 8 lines Rename PyBuiltinFunction to PyBuiltinCallable, and remake PyBuiltinFunction as a base for functions with the basic function stuff from PyBuiltinFunctionSet. Extend that with PyBuiltinFunctionNarrow for functions with a fixed set of args to match PyBuiltinMethodNarrow. Use the new function stuff to implement the builtin functions that were using ExtendedBuiltinFunction as real functions instead of PyObjects. ........ r5466 | cgroves | 2008-10-19 07:17:07 +0200 (Sun, 19 Okt 2008) | 1 line Missed a sppot ........ r5467 | pjenvey | 2008-10-19 08:51:07 +0200 (Sun, 19 Okt 2008) | 3 lines fix visitCompare leaving the left side on the stack, causing a minor short term memory leak ........ r5468 | zyasoft | 2008-10-19 17:16:29 +0200 (Sun, 19 Okt 2008) | 3 lines from http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_codeccallbacks.py@46456 ........ r5469 | pjenvey | 2008-10-19 22:51:56 +0200 (Sun, 19 Okt 2008) | 3 lines move the last visitCompare fix to after the end label so we also avoid the issue when a chained comparison fails fast ........ r5470 | zyasoft | 2008-10-20 00:04:51 +0200 (Mon, 20 Okt 2008) | 5 lines Make error handling in codecs so that it is also surrogate-aware. Fixes test_codeccallbacks Skip tests from test_threading not applicable to Jython. ........ r5471 | cgroves | 2008-10-20 01:17:44 +0200 (Mon, 20 Okt 2008) | 1 line Add a couple tests for subclass constructor visibility ........ r5472 | zyasoft | 2008-10-20 01:18:22 +0200 (Mon, 20 Okt 2008) | 7 lines PEP 342 specifies that an exception raised by close during finalization should be output to stderr, so we now do that. Fixed a minor doctest output formatting issue so that the desired syntax error is properly seen. ........ r5473 | cgroves | 2008-10-20 01:30:32 +0200 (Mon, 20 Okt 2008) | 1 line Replace StringUtil.asPyString with Py.newString ........ r5474 | pjenvey | 2008-10-20 02:44:52 +0200 (Mon, 20 Okt 2008) | 2 lines bump java's stack size to 768k on solaris, to fix test_cpickle there ........ r5475 | cgroves | 2008-10-20 03:01:39 +0200 (Mon, 20 Okt 2008) | 8 lines Add an ant resource collection that's like union except it combines based on the name of the resource instead of its full path. Use this to exclude the unexposed version of classes from jython.jar to keep it quiet. Resource collections didn't appear until Ant 1.7, but that came out nearly 2 years ago, so I'm hoping most people already have it. ........ r5476 | cgroves | 2008-10-20 03:40:25 +0200 (Mon, 20 Okt 2008) | 1 line Remove newcompiler since it's not being used now and it's going to be replaced by the advanced compiler ........ r5477 | cgroves | 2008-10-20 03:41:32 +0200 (Mon, 20 Okt 2008) | 1 line Move BaseTypeBuilder out of TypeExposer so the compile time bits of the exposing system can be excluded from jython.jar ........ r5478 | cgroves | 2008-10-20 04:03:44 +0200 (Mon, 20 Okt 2008) | 1 line Cleanup, modernization ........ r5479 | cgroves | 2008-10-20 08:29:50 +0200 (Mon, 20 Okt 2008) | 9 lines The pain of not having the generic inferring statics from Google collections finally got to the point where I felt the need to whip up version for Jython. Add Generic with static methods to make Lists, Maps and Sets that infer their generic types from the generics of whatever they're being assigned to. I went for brevity in naming the methods as I felt they'd be idiomatic enough in Jython to read well, but could be convinced that more descriptive names - newArrayList() instead of list() for example - would be better. ........ r5480 | thobes | 2008-10-20 13:13:38 +0200 (Mon, 20 Okt 2008) | 3 lines Fixed the evaluation order bug made visual by test_generators. Added a test file for evaluation order tests. ........ r5482 | thobes | 2008-10-20 19:19:57 +0200 (Mon, 20 Okt 2008) | 5 lines Added support for class decorators. The test file added for this (test_classdecorators) should be removed when we import test_decorators from CPython 3.x, because that is where the caes come from. This is also documented in that file. ........ r5483 | pjenvey | 2008-10-20 22:01:14 +0200 (Mon, 20 Okt 2008) | 2 lines make sock.listen() explicitly require the backlog argument to match CPython ........ r5484 | pjenvey | 2008-10-20 22:05:02 +0200 (Mon, 20 Okt 2008) | 4 lines revert r5474 and bump Java's stack size to 1024k, matching 64 bit Java's default. 32 bit needs an increase to at least 512k to pass test_cpickle, but we don't want to shrink 64 bit's default ........ r5485 | pjenvey | 2008-10-20 23:18:08 +0200 (Mon, 20 Okt 2008) | 5 lines o delete references to test.test_ modules in the test package after running them to conserve memory o bump ant regrtest's heap to 144m which is about the minimum needed for Apple's 64 bit Java 6 (server VM) ........ r5486 | fwierzbicki | 2008-10-20 23:37:06 +0200 (Mon, 20 Okt 2008) | 6 lines PythonPartial.g should allow decorators without classes or functions so that @foo is a valid partial sentence. ........ r5487 | pjenvey | 2008-10-21 01:53:47 +0200 (Tue, 21 Okt 2008) | 2 lines __iter__ is just another file_self call ........ r5488 | pjenvey | 2008-10-21 01:54:14 +0200 (Tue, 21 Okt 2008) | 3 lines allow abuse of _fileobject by fixing its close() to act like CPython's when the underlying _sock isn't a Jython socket. fixes test_urllib2net ........ r5489 | fwierzbicki | 2008-10-21 02:21:45 +0200 (Tue, 21 Okt 2008) | 2 lines moved test138 to test_str_jy. ........ r5490 | fwierzbicki | 2008-10-21 02:24:00 +0200 (Tue, 21 Okt 2008) | 2 lines spelling fix. ........ r5491 | fwierzbicki | 2008-10-21 02:35:49 +0200 (Tue, 21 Okt 2008) | 3 lines Charlie Groves pushed me over the "maybe the test is just dumb?" barrier. ........ r5492 | fwierzbicki | 2008-10-21 02:38:12 +0200 (Tue, 21 Okt 2008) | 3 lines This one looks like it is testing multiple inheritance of Java classes which is long gone. Also it imports a module which shouldn't exist. Deleting. ........ r5493 | fwierzbicki | 2008-10-21 02:40:02 +0200 (Tue, 21 Okt 2008) | 2 lines These three tests are well covered by existing tests. ........ r5494 | fwierzbicki | 2008-10-21 02:40:55 +0200 (Tue, 21 Okt 2008) | 2 lines This is well tested by existing unit tests. ........ r5495 | fwierzbicki | 2008-10-21 02:47:13 +0200 (Tue, 21 Okt 2008) | 2 lines Doesn't really test anything... ........ Revision Links: -------------- http://jython.svn.sourceforge.net/jython/?rev=5390&view=rev Modified Paths: -------------- branches/advanced/.classpath branches/advanced/CoreExposed.includes branches/advanced/Lib/javapath.py branches/advanced/Lib/os.py branches/advanced/Lib/socket.py branches/advanced/Lib/tarfile.py branches/advanced/Lib/test/regrtest.py branches/advanced/Lib/test/test_ast.py branches/advanced/Lib/test/test_class_jy.py branches/advanced/Lib/test/test_cmp_jy.py branches/advanced/Lib/test/test_dict_jy.py branches/advanced/Lib/test/test_exceptions.py branches/advanced/Lib/test/test_exceptions_jy.py branches/advanced/Lib/test/test_generators.py branches/advanced/Lib/test/test_java_integration.py branches/advanced/Lib/test/test_java_visibility.py branches/advanced/Lib/test/test_jy_compile.py branches/advanced/Lib/test/test_jy_internals.py branches/advanced/Lib/test/test_socket.py branches/advanced/Lib/test/test_syntax.py branches/advanced/Lib/test/test_tarfile.py branches/advanced/Lib/test/test_threading.py branches/advanced/Lib/unicodedata.py branches/advanced/Lib/zlib.py branches/advanced/NEWS branches/advanced/README.txt branches/advanced/ast/Python.asdl branches/advanced/ast/astview.py branches/advanced/ast/jastlib.py branches/advanced/bugtests/support.py branches/advanced/bugtests/test081.py branches/advanced/build.xml branches/advanced/compiler/org/python/compiler/DirectGenerator.java branches/advanced/compiler/org/python/compiler/FlowGraphGenerator.java branches/advanced/compiler/org/python/compiler/advanced/ast/AstToBytecode.java branches/advanced/grammar/Python.g branches/advanced/grammar/PythonPartial.g branches/advanced/src/com/ziclix/python/sql/DataHandler.java branches/advanced/src/com/ziclix/python/sql/JDBC20DataHandler.java branches/advanced/src/com/ziclix/python/sql/Jython22DataHandler.java branches/advanced/src/com/ziclix/python/sql/handler/InformixDataHandler.java branches/advanced/src/com/ziclix/python/sql/handler/MySQLDataHandler.java branches/advanced/src/com/ziclix/python/sql/handler/PostgresqlDataHandler.java branches/advanced/src/org/python/antlr/ExpressionParser.java branches/advanced/src/org/python/antlr/GrammarActions.java branches/advanced/src/org/python/antlr/InteractiveParser.java branches/advanced/src/org/python/antlr/PythonTokenSource.java branches/advanced/src/org/python/antlr/PythonTreeAdaptor.java branches/advanced/src/org/python/antlr/ast/ClassDef.java branches/advanced/src/org/python/antlr/ast/ErrorExpr.java branches/advanced/src/org/python/antlr/ast/ErrorMod.java branches/advanced/src/org/python/antlr/ast/ErrorSlice.java branches/advanced/src/org/python/antlr/ast/ErrorStmt.java branches/advanced/src/org/python/antlr/ast/VisitorBase.java branches/advanced/src/org/python/antlr/ast/VisitorIF.java branches/advanced/src/org/python/compiler/AdapterMaker.java branches/advanced/src/org/python/compiler/ArgListCompiler.java branches/advanced/src/org/python/compiler/ClassFile.java branches/advanced/src/org/python/compiler/Code.java branches/advanced/src/org/python/compiler/CodeCompiler.java branches/advanced/src/org/python/compiler/Constant.java branches/advanced/src/org/python/compiler/Future.java branches/advanced/src/org/python/compiler/JavaMaker.java branches/advanced/src/org/python/compiler/Module.java branches/advanced/src/org/python/compiler/ProxyMaker.java branches/advanced/src/org/python/compiler/ScopeInfo.java branches/advanced/src/org/python/compiler/ScopesCompiler.java branches/advanced/src/org/python/core/ArgParser.java branches/advanced/src/org/python/core/BytecodeLoader.java branches/advanced/src/org/python/core/ParserFacade.java branches/advanced/src/org/python/core/Py.java branches/advanced/src/org/python/core/PyArray.java branches/advanced/src/org/python/core/PyArrayDerived.java branches/advanced/src/org/python/core/PyBaseExceptionDerived.java branches/advanced/src/org/python/core/PyBeanEvent.java branches/advanced/src/org/python/core/PyBeanEventProperty.java branches/advanced/src/org/python/core/PyBooleanDerived.java branches/advanced/src/org/python/core/PyBuiltinFunction.java branches/advanced/src/org/python/core/PyBuiltinFunctionSet.java branches/advanced/src/org/python/core/PyBuiltinMethod.java branches/advanced/src/org/python/core/PyBuiltinMethodNarrow.java branches/advanced/src/org/python/core/PyBuiltinMethodSet.java branches/advanced/src/org/python/core/PyClass.java branches/advanced/src/org/python/core/PyClassMethodDerived.java branches/advanced/src/org/python/core/PyClassMethodDescr.java branches/advanced/src/org/python/core/PyComplexDerived.java branches/advanced/src/org/python/core/PyDictionary.java branches/advanced/src/org/python/core/PyDictionaryDerived.java branches/advanced/src/org/python/core/PyEnumerate.java branches/advanced/src/org/python/core/PyEnumerateDerived.java branches/advanced/src/org/python/core/PyFile.java branches/advanced/src/org/python/core/PyFileDerived.java branches/advanced/src/org/python/core/PyFloatDerived.java branches/advanced/src/org/python/core/PyFrozenSetDerived.java branches/advanced/src/org/python/core/PyFunction.java branches/advanced/src/org/python/core/PyGenerator.java branches/advanced/src/org/python/core/PyInstance.java branches/advanced/src/org/python/core/PyIntegerDerived.java branches/advanced/src/org/python/core/PyJavaClass.java branches/advanced/src/org/python/core/PyList.java branches/advanced/src/org/python/core/PyListDerived.java branches/advanced/src/org/python/core/PyLongDerived.java branches/advanced/src/org/python/core/PyMethodDescr.java branches/advanced/src/org/python/core/PyModuleDerived.java branches/advanced/src/org/python/core/PyNewWrapper.java branches/advanced/src/org/python/core/PyObject.java branches/advanced/src/org/python/core/PyObjectDerived.java branches/advanced/src/org/python/core/PyPropertyDerived.java branches/advanced/src/org/python/core/PySet.java branches/advanced/src/org/python/core/PySetDerived.java branches/advanced/src/org/python/core/PySlice.java branches/advanced/src/org/python/core/PySliceDerived.java branches/advanced/src/org/python/core/PyStringDerived.java branches/advanced/src/org/python/core/PyStringMap.java branches/advanced/src/org/python/core/PySuper.java branches/advanced/src/org/python/core/PySuperDerived.java branches/advanced/src/org/python/core/PySystemState.java branches/advanced/src/org/python/core/PyTableCode.java branches/advanced/src/org/python/core/PyTraceback.java branches/advanced/src/org/python/core/PyTupleDerived.java branches/advanced/src/org/python/core/PyType.java branches/advanced/src/org/python/core/PyTypeDerived.java branches/advanced/src/org/python/core/PyUnicode.java branches/advanced/src/org/python/core/PyUnicodeDerived.java branches/advanced/src/org/python/core/PyXRange.java branches/advanced/src/org/python/core/__builtin__.java branches/advanced/src/org/python/core/adapter/ClassicPyObjectAdapter.java branches/advanced/src/org/python/core/codecs.java branches/advanced/src/org/python/core/exceptions.java branches/advanced/src/org/python/core/imp.java branches/advanced/src/org/python/expose/generate/ExposeTask.java branches/advanced/src/org/python/expose/generate/ExposedMethodFinder.java branches/advanced/src/org/python/expose/generate/ExposedTypeProcessor.java branches/advanced/src/org/python/expose/generate/PyTypes.java branches/advanced/src/org/python/expose/generate/TypeExposer.java branches/advanced/src/org/python/modules/_collections/PyDefaultDict.java branches/advanced/src/org/python/modules/_collections/PyDefaultDictDerived.java branches/advanced/src/org/python/modules/_collections/PyDeque.java branches/advanced/src/org/python/modules/_collections/PyDequeDerived.java branches/advanced/src/org/python/modules/_csv/PyDialectDerived.java branches/advanced/src/org/python/modules/_functools/PyPartial.java branches/advanced/src/org/python/modules/_functools/PyPartialDerived.java branches/advanced/src/org/python/modules/_jython.java branches/advanced/src/org/python/modules/_weakref/ReferenceType.java branches/advanced/src/org/python/modules/_weakref/ReferenceTypeDerived.java branches/advanced/src/org/python/modules/binascii.java branches/advanced/src/org/python/modules/cPickle.java branches/advanced/src/org/python/modules/cStringIO.java branches/advanced/src/org/python/modules/operator.java branches/advanced/src/org/python/modules/random/PyRandom.java branches/advanced/src/org/python/modules/random/PyRandomDerived.java branches/advanced/src/org/python/modules/struct.java branches/advanced/src/org/python/modules/thread/PyLocalDerived.java branches/advanced/src/org/python/modules/time/Time.java branches/advanced/src/org/python/modules/zipimport/zipimporterDerived.java branches/advanced/src/org/python/util/jython.java branches/advanced/src/shell/jython branches/advanced/src/shell/jython.bat branches/advanced/src/templates/mappings branches/advanced/src/templates/object.derived branches/advanced/tests/java/org/python/antlr/PythonPartialTester.java branches/advanced/tests/java/org/python/expose/generate/ExposedTypeProcessorTest.java branches/advanced/tests/java/org/python/expose/generate/MethodExposerTest.java branches/advanced/tests/java/org/python/tests/VisibilityResults.java branches/advanced/tests/java/org/python/tests/Visible.java Added Paths: ----------- branches/advanced/Lib/test/eof_fodder1.py branches/advanced/Lib/test/eof_fodder2.py branches/advanced/Lib/test/eof_fodder3.py branches/advanced/Lib/test/eof_fodder4.py branches/advanced/Lib/test/eof_fodder5.py branches/advanced/Lib/test/eof_fodder6.py branches/advanced/Lib/test/test_StringIO_jy.py branches/advanced/Lib/test/test_asynchat.py branches/advanced/Lib/test/test_classdecorators.py branches/advanced/Lib/test/test_codeccallbacks.py branches/advanced/Lib/test/test_copy.py branches/advanced/Lib/test/test_eof_jy.py branches/advanced/Lib/test/test_evalorder.py branches/advanced/Lib/test/test_os.py branches/advanced/Lib/test/test_profilehooks.py branches/advanced/Lib/test/test_random.py branches/advanced/Lib/test/test_struct.py branches/advanced/Lib/test/test_trace.py branches/advanced/Lib/test/test_with.py branches/advanced/src/org/python/core/PyBuiltinCallable.java branches/advanced/src/org/python/core/PyBuiltinFunctionNarrow.java branches/advanced/src/org/python/expose/BaseTypeBuilder.java branches/advanced/src/org/python/modules/PyStruct.java branches/advanced/src/org/python/util/Generic.java branches/advanced/src/org/python/util/NameUnionAntType.java Removed Paths: ------------- branches/advanced/Lib/random.py branches/advanced/Lib/test/testtar.tar branches/advanced/bugtests/test049p/ branches/advanced/bugtests/test076.py branches/advanced/bugtests/test077.py branches/advanced/bugtests/test078.py branches/advanced/bugtests/test079.py branches/advanced/bugtests/test080.py branches/advanced/bugtests/test085.py branches/advanced/bugtests/test089.py branches/advanced/bugtests/test095.py branches/advanced/bugtests/test096.py branches/advanced/bugtests/test097.py branches/advanced/bugtests/test098.py branches/advanced/bugtests/test099.py branches/advanced/bugtests/test102.py branches/advanced/bugtests/test103.py branches/advanced/bugtests/test105.py branches/advanced/bugtests/test106.py branches/advanced/bugtests/test107.py branches/advanced/bugtests/test108.py branches/advanced/bugtests/test109.py branches/advanced/bugtests/test110.py branches/advanced/bugtests/test111.py branches/advanced/bugtests/test112.py branches/advanced/bugtests/test113.py branches/advanced/bugtests/test115.py branches/advanced/bugtests/test118.py branches/advanced/bugtests/test124.py branches/advanced/bugtests/test125.py branches/advanced/bugtests/test126.py branches/advanced/bugtests/test127.py branches/advanced/bugtests/test128.py branches/advanced/bugtests/test130.py branches/advanced/bugtests/test131.py branches/advanced/bugtests/test133.py branches/advanced/bugtests/test134.py branches/advanced/bugtests/test135.py branches/advanced/bugtests/test136.py branches/advanced/bugtests/test138.py branches/advanced/bugtests/test139.py branches/advanced/bugtests/test140.py branches/advanced/bugtests/test141.py branches/advanced/bugtests/test142.py branches/advanced/bugtests/test143.py branches/advanced/bugtests/test144.py branches/advanced/src/org/python/antlr/ast/Unicode.java branches/advanced/src/org/python/newcompiler/ Property Changed: ---------------- branches/advanced/ Property changes on: branches/advanced ___________________________________________________________________ Modified: svnmerge-integrated - /trunk/jython:1-5285 + /trunk/jython:1-5496 Modified: branches/advanced/.classpath =================================================================== --- branches/advanced/.classpath 2008-10-21 06:00:37 UTC (rev 5496) +++ branches/advanced/.classpath 2008-10-21 10:53:16 UTC (rev 5497) @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="lib" path="build/exposed"/> <classpathentry excluding="com/ziclix/python/sql/handler/InformixDataHandler.java|com/ziclix/python/sql/handler/OracleDataHandler.java" kind="src" output="build/classes" path="src"/> <classpathentry kind="src" output="build/classes" path="build/gensrc"/> <classpathentry kind="src" output="build/classes" path="tests/java"/> Modified: branches/advanced/CoreExposed.includes =================================================================== --- branches/advanced/CoreExposed.includes 2008-10-21 06:00:37 UTC (rev 5496) +++ branches/advanced/CoreExposed.includes 2008-10-21 10:53:16 UTC (rev 5497) @@ -2,7 +2,7 @@ org/python/core/PyBaseString.class org/python/core/PyBaseException.class org/python/core/PyBoolean.class -org/python/core/PyBuiltinFunction.class +org/python/core/PyBuiltinCallable.class org/python/core/PyCell.class org/python/core/PyClassMethod.class org/python/core/PyClassMethodDescr.class @@ -52,4 +52,5 @@ org/python/modules/thread/PyLocal.class org/python/modules/time/PyTimeTuple.class org/python/modules/zipimport/zipimporter.class +org/python/modules/PyStruct.class org/python/modules/PyTeeIterator.class Modified: branches/advanced/Lib/javapath.py =================================================================== --- branches/advanced/Lib/javapath.py 2008-10-21 06:00:37 UTC (rev 5496) +++ branches/advanced/Lib/javapath.py 2008-10-21 10:53:16 UTC (rev 5497) @@ -20,7 +20,9 @@ from java.lang import System import os +from org.python.core.Py import newString as asPyString + def _tostr(s, method): if isinstance(s, basestring): return s @@ -40,7 +42,7 @@ def dirname(path): """Return the directory component of a pathname""" path = _tostr(path, "dirname") - result = File(path).getParent() + result = asPyString(File(path).getParent()) if not result: if isabs(path): result = path # Must be root @@ -51,7 +53,7 @@ def basename(path): """Return the final component of a pathname""" path = _tostr(path, "basename") - return File(path).getName() + return asPyString(File(path).getName()) def split(path): """Split a pathname. @@ -128,7 +130,7 @@ if a == "": a = os.sep f = File(f, a) - return f.getPath() + return asPyString(f.getPath()) def normcase(path): """Normalize case of pathname. @@ -137,7 +139,7 @@ """ path = _tostr(path, "normcase") - return File(path).getPath() + return asPyString(File(path).getPath()) def commonprefix(m): "Given a list of pathnames, return the longest common leading component" @@ -197,7 +199,7 @@ if not c: return gethome() if c == os.sep: - return File(gethome(), path[2:]).getPath() + return asPyString(File(gethome(), path[2:]).getPath()) return path def getuser(): @@ -252,7 +254,7 @@ def _abspath(path): # Must use normpath separately because getAbsolutePath doesn't normalize # and getCanonicalPath would eliminate symlinks. - return normpath(File(sys.getPath(path)).getAbsolutePath()) + return normpath(asPyString(File(sys.getPath(path)).getAbsolutePath())) def realpath(path): """Return an absolute path normalized and symbolic links eliminated""" @@ -261,7 +263,7 @@ def _realpath(path): try: - return File(sys.getPath(path)).getCanonicalPath() + return asPyString(File(sys.getPath(path)).getCanonicalPath()) except java.io.IOException: return _abspath(path) Modified: branches/advanced/Lib/os.py =================================================================== --- branches/advanced/Lib/os.py 2008-10-21 06:00:37 UTC (rev 5496) +++ branches/advanced/Lib/os.py 2008-10-21 10:53:16 UTC (rev 5497) @@ -48,6 +48,7 @@ from java.io import File from org.python.core import PyFile from org.python.core.io import FileDescriptors, FileIO, IOBase +from org.python.core.Py import newString as asPyString # Mapping of: os._name: [name list, shell command list] _os_map = dict(nt=[ @@ -205,15 +206,15 @@ if i < 0 or i > 9: raise IndexError(i) return getattr(self, stat_result._stat_members[i][0]) - + def __setitem__(self, x, value): raise TypeError("object doesn't support item assignment") - + def __setattr__(self, name, value): if name in [x[0] for x in stat_result._stat_members]: raise TypeError(name) raise AttributeError("readonly attribute") - + def __len__(self): return 10 @@ -264,7 +265,7 @@ l = File(sys.getPath(path)).list() if l is None: raise OSError(0, 'No such directory', path) - return list(l) + return [asPyString(entry) for entry in l] def chmod(path, mode): """chmod(path, mode) @@ -303,14 +304,14 @@ # if making a /x/y/z/., java.io.File#mkdirs inexplicably fails. So we need # to force it - + # need to use _path instead of path, because param is hiding # os.path module in namespace! head, tail = _path.split(sys_path) if tail == curdir: if File(_path.join(head)).mkdirs(): return - + raise OSError(0, "couldn't make directories", path) def remove(path): @@ -362,7 +363,12 @@ """rmdir(path) Remove a directory.""" - if not File(sys.getPath(path)).delete(): + f = File(sys.getPath(path)) + if not f.exists(): + raise OSError(errno.ENOENT, errno.strerror(errno.ENOENT), path) + elif not f.isDirectory(): + raise OSError(errno.ENOTDIR, errno.strerror(errno.ENOTDIR), path) + elif not f.delete(): raise OSError(0, "couldn't delete directory", path) #XXX: copied from CPython 2.5.1 @@ -392,7 +398,7 @@ def strerror(code): """strerror(code) -> string - + Translate an error code to a message string. """ if not isinstance(code, (int, long)): @@ -404,7 +410,7 @@ def access(path, mode): """access(path, mode) -> True if granted, False otherwise - + Use the real uid/gid to test for access to a path. Note that most operations will use the effective uid/gid, therefore this routine can be used in a suid/sgid environment to test if the invoking user has the @@ -415,15 +421,20 @@ raise TypeError('an integer is required') f = File(sys.getPath(path)) + result = True if not f.exists(): - return False + result = False if mode & R_OK and not f.canRead(): - return False + result = False if mode & W_OK and not f.canWrite(): - return False + result = False if mode & X_OK: - return False - return True + # NOTE: always False without jna-posix stat + try: + result = (stat(path).st_mode & _stat.S_IEXEC) != 0 + except OSError: + result = False + return result def stat(path): """stat(path) -> stat result @@ -458,7 +469,7 @@ def lstat(path): """lstat(path) -> stat result - + Like stat(path), but do not follow symbolic links. """ abs_path = sys.getPath(path) @@ -545,7 +556,7 @@ """ftruncate(fd, length) Truncate a file to a specified length. - """ + """ rawio = FileDescriptors.get(fd) try: rawio.truncate(length) @@ -624,7 +635,7 @@ from org.python.core.util import StringUtil rawio = FileDescriptors.get(fd) buf = _handle_oserror(rawio.read, buffersize) - return str(StringUtil.fromBytes(buf)) + return asPyString(StringUtil.fromBytes(buf)) def write(fd, string): """write(fd, string) -> byteswritten @@ -647,7 +658,7 @@ if _name == 'posix' and _native_posix: def link(src, dst): """link(src, dst) - + Create a hard link to a file. """ _posix.link(sys.getPath(src), sys.getPath(dst)) @@ -661,7 +672,7 @@ def readlink(path): """readlink(path) -> path - + Return a string representing the path to which the symbolic link points. """ @@ -863,7 +874,7 @@ def putenv(key, value): """putenv(key, value) - + Change or add an environment variable. """ environ[key] = value Deleted: branches/advanced/Lib/random.py =================================================================== --- branches/advanced/Lib/random.py 2008-10-21 06:00:37 UTC (rev 5496) +++ branches/advanced/Lib/random.py 2008-10-21 10:53:16 UTC (rev 5497) @@ -1,863 +0,0 @@ -"""Random variable generators. - - integers - -------- - uniform within range - - sequences - --------- - pick random element - pick random sample - generate random permutation - - distributions on the real line: - ------------------------------ - uniform - normal (Gaussian) - lognormal - negative exponential - gamma - beta - pareto - Weibull - - distributions on the circle (angles 0 to 2pi) - --------------------------------------------- - circular uniform - ... [truncated message content] |
From: <otm...@us...> - 2008-10-21 06:00:40
|
Revision: 5496 http://jython.svn.sourceforge.net/jython/?rev=5496&view=rev Author: otmarhumbel Date: 2008-10-21 06:00:37 +0000 (Tue, 21 Oct 2008) Log Message: ----------- really solve the open file problem Modified Paths: -------------- trunk/installer/src/java/org/python/util/install/StartScriptGenerator.java trunk/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java Modified: trunk/installer/src/java/org/python/util/install/StartScriptGenerator.java =================================================================== --- trunk/installer/src/java/org/python/util/install/StartScriptGenerator.java 2008-10-21 00:47:13 UTC (rev 5495) +++ trunk/installer/src/java/org/python/util/install/StartScriptGenerator.java 2008-10-21 06:00:37 UTC (rev 5496) @@ -189,13 +189,17 @@ file = new File(_targetDirectory, fileName); } FileReader fileReader = new FileReader(file); - StringBuffer sb = new StringBuffer(); - char[] b = new char[8192]; - int n; - while ((n = fileReader.read(b)) > 0) { - sb.append(b, 0, n); + try { + StringBuffer sb = new StringBuffer(); + char[] b = new char[8192]; + int n; + while ((n = fileReader.read(b)) > 0) { + sb.append(b, 0, n); + } + return sb.toString(); + } finally { + fileReader.close(); } - return sb.toString(); } /** Modified: trunk/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java =================================================================== --- trunk/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java 2008-10-21 00:47:13 UTC (rev 5495) +++ trunk/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java 2008-10-21 06:00:37 UTC (rev 5496) @@ -144,10 +144,6 @@ assertTrue(fileNamesSet.contains("jython")); assertTrue(fileNamesSet.contains("jython.bat")); } finally { - try { - // give windows some time to release file locks - Thread.sleep(500); - } catch (InterruptedException e) {} if (dir.exists()) { rmdir(dir); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-10-21 00:47:19
|
Revision: 5495 http://jython.svn.sourceforge.net/jython/?rev=5495&view=rev Author: fwierzbicki Date: 2008-10-21 00:47:13 +0000 (Tue, 21 Oct 2008) Log Message: ----------- Doesn't really test anything... Removed Paths: ------------- trunk/jython/bugtests/test143.py Deleted: trunk/jython/bugtests/test143.py =================================================================== --- trunk/jython/bugtests/test143.py 2008-10-21 00:40:55 UTC (rev 5494) +++ trunk/jython/bugtests/test143.py 2008-10-21 00:47:13 UTC (rev 5495) @@ -1,10 +0,0 @@ -""" - -""" - -import support - -import java - -hasattr(java.awt.Rectangle, "getSize") -hasattr(java.awt.Rectangle, "size") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-10-21 00:41:02
|
Revision: 5494 http://jython.svn.sourceforge.net/jython/?rev=5494&view=rev Author: fwierzbicki Date: 2008-10-21 00:40:55 +0000 (Tue, 21 Oct 2008) Log Message: ----------- This is well tested by existing unit tests. Removed Paths: ------------- trunk/jython/bugtests/test141.py Deleted: trunk/jython/bugtests/test141.py =================================================================== --- trunk/jython/bugtests/test141.py 2008-10-21 00:40:02 UTC (rev 5493) +++ trunk/jython/bugtests/test141.py 2008-10-21 00:40:55 UTC (rev 5494) @@ -1,17 +0,0 @@ -""" - -""" - -import support - -import exceptions - -class A(exceptions.Exception): - def __init__(self, args): - exceptions.Exception.__init__(self, args) - - -support.compare(A, "test141.A|__main__.A") - -#print support.TestError - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-10-21 00:40:09
|
Revision: 5493 http://jython.svn.sourceforge.net/jython/?rev=5493&view=rev Author: fwierzbicki Date: 2008-10-21 00:40:02 +0000 (Tue, 21 Oct 2008) Log Message: ----------- These three tests are well covered by existing tests. Removed Paths: ------------- trunk/jython/bugtests/test140.py trunk/jython/bugtests/test142.py trunk/jython/bugtests/test144.py Deleted: trunk/jython/bugtests/test140.py =================================================================== --- trunk/jython/bugtests/test140.py 2008-10-21 00:38:12 UTC (rev 5492) +++ trunk/jython/bugtests/test140.py 2008-10-21 00:40:02 UTC (rev 5493) @@ -1,17 +0,0 @@ -""" -Check calling an instance method with a class instance. -""" - -import support - -class foo: - def bar(): return "bar" - -try: - foo.bar() -except TypeError, e: - support.compare(e, "with \w* ?instance") -else: - raise support.TestError("Should raise TypeError") - - Deleted: trunk/jython/bugtests/test142.py =================================================================== --- trunk/jython/bugtests/test142.py 2008-10-21 00:38:12 UTC (rev 5492) +++ trunk/jython/bugtests/test142.py 2008-10-21 00:40:02 UTC (rev 5493) @@ -1,17 +0,0 @@ -""" -Calling constructor on PyObject subclasses from python. -""" - -import support - -support.compileJava("classes/test142j.java") - -import test142j - -a = test142j([1.1, 1.2, 1.3]) -support.compare(a.__repr__(), "1.1, 1.2, 1.3") - -b = test142j.new([1.1, 1.2, 1.3, 1.4]) -support.compare(b.__repr__(), "1.1, 1.2, 1.3, 1.4") - - Deleted: trunk/jython/bugtests/test144.py =================================================================== --- trunk/jython/bugtests/test144.py 2008-10-21 00:38:12 UTC (rev 5492) +++ trunk/jython/bugtests/test144.py 2008-10-21 00:40:02 UTC (rev 5493) @@ -1,15 +0,0 @@ -""" - -""" - -import support - -class m: - __var = 0 - -try: - m.__var -except AttributeError, e: - support.compare(e, "class 'm' has no attribute '__var'") -else: - raise support.TestError("Should raise") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-10-21 00:38:22
|
Revision: 5492 http://jython.svn.sourceforge.net/jython/?rev=5492&view=rev Author: fwierzbicki Date: 2008-10-21 00:38:12 +0000 (Tue, 21 Oct 2008) Log Message: ----------- This one looks like it is testing multiple inheritance of Java classes which is long gone. Also it imports a module which shouldn't exist. Deleting. Removed Paths: ------------- trunk/jython/bugtests/test139.py Deleted: trunk/jython/bugtests/test139.py =================================================================== --- trunk/jython/bugtests/test139.py 2008-10-21 00:35:49 UTC (rev 5491) +++ trunk/jython/bugtests/test139.py 2008-10-21 00:38:12 UTC (rev 5492) @@ -1,19 +0,0 @@ -""" - -""" - -import support - -support.compileJava("classes/test139j2.java") -support.compileJava("classes/test139j3.java") - -import test139j1, test139j2 - -class myclass(test139j1, test139j2): - def fooMethod(self): - pass - -import test139j3 - -if not test139j3.baz(myclass()): - raise support.TestError("myclass should implement test139j2") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-10-21 00:35:51
|
Revision: 5491 http://jython.svn.sourceforge.net/jython/?rev=5491&view=rev Author: fwierzbicki Date: 2008-10-21 00:35:49 +0000 (Tue, 21 Oct 2008) Log Message: ----------- Charlie Groves pushed me over the "maybe the test is just dumb?" barrier. Modified Paths: -------------- trunk/jython/Lib/test/test_str_jy.py Modified: trunk/jython/Lib/test/test_str_jy.py =================================================================== --- trunk/jython/Lib/test/test_str_jy.py 2008-10-21 00:24:00 UTC (rev 5490) +++ trunk/jython/Lib/test/test_str_jy.py 2008-10-21 00:35:49 UTC (rev 5491) @@ -130,12 +130,6 @@ self.assertEqual(repr(test2), '"\'bar"') self.assertEqual(repr(unicode(test2)), 'u"\'bar"') - def test_startswith(self): - #from bugtests -- maybe making sure methods are case sensitive? - msg = 'This is a test.' - self.assertRaises(AttributeError, getattr, msg, "startsWith") - assert msg.startswith('This') - def test_main(): test_support.run_unittest(WrappedStrCmpTest, IntToStrTest, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-10-21 00:24:05
|
Revision: 5490 http://jython.svn.sourceforge.net/jython/?rev=5490&view=rev Author: fwierzbicki Date: 2008-10-21 00:24:00 +0000 (Tue, 21 Oct 2008) Log Message: ----------- spelling fix. Modified Paths: -------------- trunk/jython/Lib/test/test_str_jy.py Modified: trunk/jython/Lib/test/test_str_jy.py =================================================================== --- trunk/jython/Lib/test/test_str_jy.py 2008-10-21 00:21:45 UTC (rev 5489) +++ trunk/jython/Lib/test/test_str_jy.py 2008-10-21 00:24:00 UTC (rev 5490) @@ -131,7 +131,7 @@ self.assertEqual(repr(unicode(test2)), 'u"\'bar"') def test_startswith(self): - #from bugtests -- maybe making sure methods are case sensative? + #from bugtests -- maybe making sure methods are case sensitive? msg = 'This is a test.' self.assertRaises(AttributeError, getattr, msg, "startsWith") assert msg.startswith('This') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-10-21 00:21:56
|
Revision: 5489 http://jython.svn.sourceforge.net/jython/?rev=5489&view=rev Author: fwierzbicki Date: 2008-10-21 00:21:45 +0000 (Tue, 21 Oct 2008) Log Message: ----------- moved test138 to test_str_jy. Modified Paths: -------------- trunk/jython/Lib/test/test_str_jy.py Removed Paths: ------------- trunk/jython/bugtests/test138.py Modified: trunk/jython/Lib/test/test_str_jy.py =================================================================== --- trunk/jython/Lib/test/test_str_jy.py 2008-10-20 23:54:14 UTC (rev 5488) +++ trunk/jython/Lib/test/test_str_jy.py 2008-10-21 00:21:45 UTC (rev 5489) @@ -130,6 +130,12 @@ self.assertEqual(repr(test2), '"\'bar"') self.assertEqual(repr(unicode(test2)), 'u"\'bar"') + def test_startswith(self): + #from bugtests -- maybe making sure methods are case sensative? + msg = 'This is a test.' + self.assertRaises(AttributeError, getattr, msg, "startsWith") + assert msg.startswith('This') + def test_main(): test_support.run_unittest(WrappedStrCmpTest, IntToStrTest, Deleted: trunk/jython/bugtests/test138.py =================================================================== --- trunk/jython/bugtests/test138.py 2008-10-20 23:54:14 UTC (rev 5488) +++ trunk/jython/bugtests/test138.py 2008-10-21 00:21:45 UTC (rev 5489) @@ -1,17 +0,0 @@ -""" - -""" - -import support - -msg = 'This is a test.' - -try: - msg.startsWith('This') -except AttributeError, e: - pass -else: - raise support.TestError("startsWith should not be defined") - -if not msg.startswith('This'): - raise support.TestError("startswith error") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-10-20 23:54:18
|
Revision: 5488 http://jython.svn.sourceforge.net/jython/?rev=5488&view=rev Author: pjenvey Date: 2008-10-20 23:54:14 +0000 (Mon, 20 Oct 2008) Log Message: ----------- allow abuse of _fileobject by fixing its close() to act like CPython's when the underlying _sock isn't a Jython socket. fixes test_urllib2net Modified Paths: -------------- trunk/jython/Lib/socket.py Modified: trunk/jython/Lib/socket.py =================================================================== --- trunk/jython/Lib/socket.py 2008-10-20 23:53:47 UTC (rev 5487) +++ trunk/jython/Lib/socket.py 2008-10-20 23:54:14 UTC (rev 5488) @@ -1114,9 +1114,12 @@ if self._sock: self.flush() finally: - if self._sock and isinstance(self._sock, _nonblocking_api_mixin): - self._sock.reference_count -= 1 - if not self._sock.reference_count or self._close: + if self._sock: + if isinstance(self._sock, _nonblocking_api_mixin): + self._sock.reference_count -= 1 + if not self._sock.reference_count or self._close: + self._sock.close() + elif self._close: self._sock.close() self._sock = None This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-10-20 23:53:49
|
Revision: 5487 http://jython.svn.sourceforge.net/jython/?rev=5487&view=rev Author: pjenvey Date: 2008-10-20 23:53:47 +0000 (Mon, 20 Oct 2008) Log Message: ----------- __iter__ is just another file_self call Modified Paths: -------------- trunk/jython/src/org/python/core/PyFile.java Modified: trunk/jython/src/org/python/core/PyFile.java =================================================================== --- trunk/jython/src/org/python/core/PyFile.java 2008-10-20 21:37:06 UTC (rev 5486) +++ trunk/jython/src/org/python/core/PyFile.java 2008-10-20 23:53:47 UTC (rev 5487) @@ -349,16 +349,6 @@ return file_readlines(0); } - public PyObject __iter__() { - return file___iter__(); - } - - @ExposedMethod - final PyObject file___iter__() { - checkClosed(); - return this; - } - public PyObject __iternext__() { return file___iternext__(); } @@ -385,7 +375,7 @@ return file_next(); } - @ExposedMethod(names = {"__enter__", "xreadlines"}) + @ExposedMethod(names = {"__enter__", "__iter__", "xreadlines"}) final PyObject file_self() { checkClosed(); return this; @@ -395,6 +385,10 @@ return file_self(); } + public PyObject __iter__() { + return file_self(); + } + public PyObject xreadlines() { return file_self(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-10-20 21:37:12
|
Revision: 5486 http://jython.svn.sourceforge.net/jython/?rev=5486&view=rev Author: fwierzbicki Date: 2008-10-20 21:37:06 +0000 (Mon, 20 Oct 2008) Log Message: ----------- PythonPartial.g should allow decorators without classes or functions so that @foo is a valid partial sentence. Modified Paths: -------------- trunk/jython/grammar/PythonPartial.g Modified: trunk/jython/grammar/PythonPartial.g =================================================================== --- trunk/jython/grammar/PythonPartial.g 2008-10-20 21:18:08 UTC (rev 5485) +++ trunk/jython/grammar/PythonPartial.g 2008-10-20 21:37:06 UTC (rev 5486) @@ -455,7 +455,8 @@ dictmaker : test COLON test (options {k=2;}:COMMA test COLON test)* (COMMA)? ; -classdef: decorators? CLASS NAME (LPAREN testlist? RPAREN)? COLON suite +classdef: decorators (CLASS NAME (LPAREN testlist? RPAREN)? COLON suite)? + | CLASS NAME (LPAREN testlist? RPAREN)? COLON suite ; arglist : argument (COMMA argument)* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-10-20 21:18:17
|
Revision: 5485 http://jython.svn.sourceforge.net/jython/?rev=5485&view=rev Author: pjenvey Date: 2008-10-20 21:18:08 +0000 (Mon, 20 Oct 2008) Log Message: ----------- o delete references to test.test_ modules in the test package after running them to conserve memory o bump ant regrtest's heap to 144m which is about the minimum needed for Apple's 64 bit Java 6 (server VM) Modified Paths: -------------- trunk/jython/Lib/test/regrtest.py trunk/jython/build.xml Modified: trunk/jython/Lib/test/regrtest.py =================================================================== --- trunk/jython/Lib/test/regrtest.py 2008-10-20 20:05:02 UTC (rev 5484) +++ trunk/jython/Lib/test/regrtest.py 2008-10-20 21:18:08 UTC (rev 5485) @@ -168,6 +168,7 @@ newsoft = min(hard, max(soft, 1024*2048)) resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard)) +import test as _test from test import test_support RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb', @@ -416,6 +417,9 @@ for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) + module = module[5:] + if hasattr(_test, module): + delattr(_test, module) # The lists won't be sorted if running with -r good.sort() Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2008-10-20 20:05:02 UTC (rev 5484) +++ trunk/jython/build.xml 2008-10-20 21:18:08 UTC (rev 5485) @@ -171,7 +171,9 @@ <pathelement path="${exposed.dir}" /> <pathelement path="${compile.dir}" /> </path> - <property name="regrtest.Xmx" value="-Xmx96m" /> + <!-- 64 bit Java 6 needs about 96m for regrtest on most platforms, but Apple's needs + 144m --> + <property name="regrtest.Xmx" value="-Xmx144m" /> </target> <target name="version-init"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-10-20 20:05:06
|
Revision: 5484 http://jython.svn.sourceforge.net/jython/?rev=5484&view=rev Author: pjenvey Date: 2008-10-20 20:05:02 +0000 (Mon, 20 Oct 2008) Log Message: ----------- revert r5474 and bump Java's stack size to 1024k, matching 64 bit Java's default. 32 bit needs an increase to at least 512k to pass test_cpickle, but we don't want to shrink 64 bit's default Modified Paths: -------------- trunk/jython/src/shell/jython Modified: trunk/jython/src/shell/jython =================================================================== --- trunk/jython/src/shell/jython 2008-10-20 20:01:14 UTC (rev 5483) +++ trunk/jython/src/shell/jython 2008-10-20 20:05:02 UTC (rev 5484) @@ -13,12 +13,10 @@ # ----------------------------------------------------------------------------- cygwin=false -solaris=false # ----- Identify OS we are running under -------------------------------------- case "`uname`" in - CYGWIN*) cygwin=true;; - SunOS*) solaris=true;; + CYGWIN*) cygwin=true esac # ----- Verify and set required environment variables ------------------------- @@ -83,12 +81,11 @@ # ----- Execute the requested command ----------------------------------------- -# stack size value determined by the minimum requirement for -# test_cpickle -if $solaris; then - JAVA_STACK=-Xss768k -else - JAVA_STACK=-Xss512k +if [ -z "$JAVA_STACK" ]; then + # 32 bit Java 6 needs the stack increased to at least 512k for + # test_cpickle to pass, but we don't want to shrink 64 bit Java's + # default of 1024k + JAVA_STACK=-Xss1024k fi # Split out any -J argument for passing to the JVM. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-10-20 20:01:24
|
Revision: 5483 http://jython.svn.sourceforge.net/jython/?rev=5483&view=rev Author: pjenvey Date: 2008-10-20 20:01:14 +0000 (Mon, 20 Oct 2008) Log Message: ----------- make sock.listen() explicitly require the backlog argument to match CPython Modified Paths: -------------- trunk/jython/Lib/socket.py trunk/jython/Lib/test/test_socket.py Modified: trunk/jython/Lib/socket.py =================================================================== --- trunk/jython/Lib/socket.py 2008-10-20 17:19:57 UTC (rev 5482) +++ trunk/jython/Lib/socket.py 2008-10-20 20:01:14 UTC (rev 5483) @@ -699,7 +699,7 @@ _unpack_address_tuple(addr) self.local_addr = addr - def listen(self, backlog=50): + def listen(self, backlog): "This signifies a server socket" try: assert not self.sock_impl Modified: trunk/jython/Lib/test/test_socket.py =================================================================== --- trunk/jython/Lib/test/test_socket.py 2008-10-20 17:19:57 UTC (rev 5482) +++ trunk/jython/Lib/test/test_socket.py 2008-10-20 20:01:14 UTC (rev 5483) @@ -543,7 +543,7 @@ # First listen on a server socket, so that the connection won't be refused. server_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_sock.bind( (HOST, PORT) ) - server_sock.listen() + server_sock.listen(50) # Now do the tests sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self._testSetAndGetOption(sock, option, values) @@ -564,7 +564,7 @@ self._testSetAndGetOption(sock, option, values) # now bind and listen on the socket i.e. cause the implementation socket to be created sock.bind( (HOST, PORT) ) - sock.listen() + sock.listen(50) self.failUnlessEqual(sock.getsockopt(socket.SOL_SOCKET, option), values[-1], \ "Option value '%s'='%s' did not propagate to implementation socket" % (option, values[-1])) self._testSetAndGetOption(sock, option, values) @@ -1410,12 +1410,12 @@ def testBindException(self): # First bind to the target port self.s.bind( (HOST, PORT) ) - self.s.listen() + self.s.listen(50) try: # And then try to bind again t = socket.socket(socket.AF_INET, socket.SOCK_STREAM) t.bind( (HOST, PORT) ) - t.listen() + t.listen(50) except socket.error, se: self.failUnlessEqual(se[0], errno.EADDRINUSE) except Exception, x: @@ -1493,7 +1493,7 @@ self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def testShutdownIOOnListener(self): - self.socket.listen() # socket is now a server socket + self.socket.listen(50) # socket is now a server socket try: self.socket.shutdown(socket.SHUT_RDWR) except Exception, x: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2008-10-20 17:20:08
|
Revision: 5482 http://jython.svn.sourceforge.net/jython/?rev=5482&view=rev Author: thobes Date: 2008-10-20 17:19:57 +0000 (Mon, 20 Oct 2008) Log Message: ----------- Added support for class decorators. The test file added for this (test_classdecorators) should be removed when we import test_decorators from CPython 3.x, because that is where the caes come from. This is also documented in that file. Modified Paths: -------------- trunk/jython/Lib/test/test_ast.py trunk/jython/ast/Python.asdl trunk/jython/grammar/Python.g trunk/jython/grammar/PythonPartial.g trunk/jython/src/org/python/antlr/GrammarActions.java trunk/jython/src/org/python/antlr/ast/ClassDef.java trunk/jython/src/org/python/compiler/CodeCompiler.java Added Paths: ----------- trunk/jython/Lib/test/test_classdecorators.py Modified: trunk/jython/Lib/test/test_ast.py =================================================================== --- trunk/jython/Lib/test/test_ast.py 2008-10-20 11:50:13 UTC (rev 5481) +++ trunk/jython/Lib/test/test_ast.py 2008-10-20 17:19:57 UTC (rev 5482) @@ -168,14 +168,15 @@ (eval_tests, eval_results, "eval")): for i, o in itertools.izip(input, output): ast_tree = compile(i, "?", kind, 0x400) - assert to_tuple(ast_tree) == o + assert to_tuple(ast_tree) == o, "expected %s, got %s" % ( + o, to_tuple(ast_tree)) test_order(ast_tree, (0, 0)) # XXX: AugStore added for Jython. Short term it is too hard to emit just "Store" as CPython does. #### EVERYTHING BELOW IS GENERATED ##### exec_results = [ ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Pass', (1, 9))], [])]), -('Module', [('ClassDef', (1, 0), 'C', [], [('Pass', (1, 8))])]), +('Module', [('ClassDef', (1, 0), 'C', [], [('Pass', (1, 8))],[])]), ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Return', (1, 8), ('Num', (1, 15), 1))], [])]), ('Module', [('Delete', (1, 0), [('Name', (1, 4), 'v', ('Del',))])]), ('Module', [('Assign', (1, 0), [('Name', (1, 0), 'v', ('Store',))], ('Num', (1, 4), 1))]), Added: trunk/jython/Lib/test/test_classdecorators.py =================================================================== --- trunk/jython/Lib/test/test_classdecorators.py (rev 0) +++ trunk/jython/Lib/test/test_classdecorators.py 2008-10-20 17:19:57 UTC (rev 5482) @@ -0,0 +1,46 @@ +# This test is temporary until we can import test_decorators from CPython 3.x +# The reason for not doing that already is that in Python 3.x the name of a +# function is stored in func.__name__, in 2.x it's func.func_name +import unittest +from test import test_support + +class TestClassDecorators(unittest.TestCase): + + def test_simple(self): + def plain(x): + x.extra = 'Hello' + return x + @plain + class C(object): pass + self.assertEqual(C.extra, 'Hello') + + def test_double(self): + def ten(x): + x.extra = 10 + return x + def add_five(x): + x.extra += 5 + return x + + @add_five + @ten + class C(object): pass + self.assertEqual(C.extra, 15) + + def test_order(self): + def applied_first(x): + x.extra = 'first' + return x + def applied_second(x): + x.extra = 'second' + return x + @applied_second + @applied_first + class C(object): pass + self.assertEqual(C.extra, 'second') + +def test_main(): + test_support.run_unittest(TestClassDecorators) + +if __name__ == '__main__': + test_main() Modified: trunk/jython/ast/Python.asdl =================================================================== --- trunk/jython/ast/Python.asdl 2008-10-20 11:50:13 UTC (rev 5481) +++ trunk/jython/ast/Python.asdl 2008-10-20 17:19:57 UTC (rev 5482) @@ -11,7 +11,8 @@ stmt = FunctionDef(identifier name, arguments args, stmt* body, expr* decorators) - | ClassDef(identifier name, expr* bases, stmt* body) + | ClassDef(identifier name, expr* bases, + stmt* body, expr* decorators) | Return(expr? value) | Delete(expr* targets) Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2008-10-20 11:50:13 UTC (rev 5481) +++ trunk/jython/grammar/Python.g 2008-10-20 17:19:57 UTC (rev 5482) @@ -800,7 +800,7 @@ | for_stmt | try_stmt | with_stmt - | funcdef + | (decorators? DEF) => funcdef | classdef ; @@ -1421,10 +1421,16 @@ @after { $classdef.tree = stype; } - : CLASS NAME (LPAREN testlist[expr_contextType.Load]? RPAREN)? COLON suite[false] + : decorators? CLASS NAME (LPAREN testlist[expr_contextType.Load]? RPAREN)? COLON suite[false] { - stype = new ClassDef($CLASS, actions.cantBeNone($NAME), actions.makeBases(actions.castExpr($testlist.tree)), - actions.castStmts($suite.stypes)); + Token t = $CLASS; + if ($decorators.start != null) { + t = $decorators.start; + } + stype = new ClassDef(t, actions.cantBeNone($NAME), + actions.makeBases(actions.castExpr($testlist.tree)), + actions.castStmts($suite.stypes), + actions.castExprs($decorators.etypes)); } ; Modified: trunk/jython/grammar/PythonPartial.g =================================================================== --- trunk/jython/grammar/PythonPartial.g 2008-10-20 11:50:13 UTC (rev 5481) +++ trunk/jython/grammar/PythonPartial.g 2008-10-20 17:19:57 UTC (rev 5482) @@ -298,7 +298,7 @@ | for_stmt | try_stmt | with_stmt - | funcdef + | (decorators? DEF) => funcdef | classdef ; @@ -455,7 +455,7 @@ dictmaker : test COLON test (options {k=2;}:COMMA test COLON test)* (COMMA)? ; -classdef: CLASS NAME (LPAREN testlist? RPAREN)? COLON suite +classdef: decorators? CLASS NAME (LPAREN testlist? RPAREN)? COLON suite ; arglist : argument (COMMA argument)* Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2008-10-20 11:50:13 UTC (rev 5481) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2008-10-20 17:19:57 UTC (rev 5482) @@ -489,14 +489,15 @@ return new Interactive(t, s); } - stmtType makeClassDef(PythonTree t, PythonTree nameToken, List bases, List body) { + stmtType makeClassDef(PythonTree t, PythonTree nameToken, List bases, List body, List decorators) { if (nameToken == null) { return errorHandler.errorStmt(t); } cantBeNone(nameToken); exprType[] b = castExprs(bases); stmtType[] s = castStmts(body); - return new ClassDef(t, nameToken.getText(), b, s); + exprType[] d = castExprs(decorators); + return new ClassDef(t, nameToken.getText(), b, s, d); } stmtType makeTryExcept(PythonTree t, List body, List handlers, List orelse, List finBody) { Modified: trunk/jython/src/org/python/antlr/ast/ClassDef.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ClassDef.java 2008-10-20 11:50:13 UTC (rev 5481) +++ trunk/jython/src/org/python/antlr/ast/ClassDef.java 2008-10-20 17:19:57 UTC (rev 5482) @@ -10,11 +10,13 @@ public String name; public exprType[] bases; public stmtType[] body; + public exprType[] decorators; - public static final String[] _fields = new String[] {"name","bases","body"}; + public static final String[] _fields = new String[] + {"name","bases","body","decorators"}; public ClassDef(Token token, String name, exprType[] bases, stmtType[] - body) { + body, exprType[] decorators) { super(token); this.name = name; this.bases = bases; @@ -29,10 +31,16 @@ addChild(body[ibody]); } } + this.decorators = decorators; + if (decorators != null) { + for(int idecorators=0;idecorators<decorators.length;idecorators++) { + addChild(decorators[idecorators]); + } + } } public ClassDef(int ttype, Token token, String name, exprType[] bases, - stmtType[] body) { + stmtType[] body, exprType[] decorators) { super(ttype, token); this.name = name; this.bases = bases; @@ -47,10 +55,16 @@ addChild(body[ibody]); } } + this.decorators = decorators; + if (decorators != null) { + for(int idecorators=0;idecorators<decorators.length;idecorators++) { + addChild(decorators[idecorators]); + } + } } public ClassDef(PythonTree tree, String name, exprType[] bases, stmtType[] - body) { + body, exprType[] decorators) { super(tree); this.name = name; this.bases = bases; @@ -65,6 +79,12 @@ addChild(body[ibody]); } } + this.decorators = decorators; + if (decorators != null) { + for(int idecorators=0;idecorators<decorators.length;idecorators++) { + addChild(decorators[idecorators]); + } + } } public String toString() { @@ -82,6 +102,9 @@ sb.append("body="); sb.append(dumpThis(body)); sb.append(","); + sb.append("decorators="); + sb.append(dumpThis(decorators)); + sb.append(","); sb.append(")"); return sb.toString(); } @@ -103,6 +126,12 @@ body[i].accept(visitor); } } + if (decorators != null) { + for (int i = 0; i < decorators.length; i++) { + if (decorators[i] != null) + decorators[i].accept(visitor); + } + } } public int getLineno() { Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2008-10-20 11:50:13 UTC (rev 5481) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2008-10-20 17:19:57 UTC (rev 5482) @@ -422,19 +422,18 @@ } set(new Name(node, node.name, expr_contextType.Store)); - doDecorators(node); + doDecorators(node, node.decorators, node.name); return null; } - private void doDecorators(FunctionDef func) throws Exception { - if (func.decorators.length > 0) { - exprType currentExpr = new Name(func, func.name, expr_contextType.Load); - exprType[] decs = func.decorators; + private void doDecorators(stmtType node, exprType[] decs, String name) throws Exception { + if (decs.length > 0) { + exprType currentExpr = new Name(node, name, expr_contextType.Load); for (int i=decs.length - 1;i > -1;i--) { - currentExpr = new Call(func, decs[i], new exprType[]{currentExpr}, new keywordType[0], null, null); + currentExpr = new Call(node, decs[i], new exprType[]{currentExpr}, new keywordType[0], null, null); } visit(currentExpr); - set(new Name(func, func.name, expr_contextType.Store)); + set(new Name(node, name, expr_contextType.Store)); } } @@ -2007,6 +2006,7 @@ //Assign this new class to the given name set(new Name(node, node.name, expr_contextType.Store)); + doDecorators(node, node.decorators, node.name); return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2008-10-20 11:50:15
|
Revision: 5481 http://jython.svn.sourceforge.net/jython/?rev=5481&view=rev Author: otmarhumbel Date: 2008-10-20 11:50:13 +0000 (Mon, 20 Oct 2008) Log Message: ----------- installer test suite now passes on windows again 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-10-20 11:13:38 UTC (rev 5480) +++ trunk/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java 2008-10-20 11:50:13 UTC (rev 5481) @@ -144,17 +144,22 @@ assertTrue(fileNamesSet.contains("jython")); assertTrue(fileNamesSet.contains("jython.bat")); } finally { + try { + // give windows some time to release file locks + Thread.sleep(500); + } catch (InterruptedException e) {} if (dir.exists()) { rmdir(dir); } } } - private void rmdir(File dir) { + private void rmdir(File dir) throws IOException { File[] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isFile()) { - Assert.assertTrue(files[i].delete()); + Assert.assertTrue("unable to delete '" + files[i].getCanonicalPath() + "'", + files[i].delete()); } else { if (files[i].isDirectory()) { rmdir(files[i]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2008-10-20 11:13:43
|
Revision: 5480 http://jython.svn.sourceforge.net/jython/?rev=5480&view=rev Author: thobes Date: 2008-10-20 11:13:38 +0000 (Mon, 20 Oct 2008) Log Message: ----------- Fixed the evaluation order bug made visual by test_generators. Added a test file for evaluation order tests. Modified Paths: -------------- trunk/jython/src/org/python/compiler/CodeCompiler.java Added Paths: ----------- trunk/jython/Lib/test/test_evalorder.py Added: trunk/jython/Lib/test/test_evalorder.py =================================================================== --- trunk/jython/Lib/test/test_evalorder.py (rev 0) +++ trunk/jython/Lib/test/test_evalorder.py 2008-10-20 11:13:38 UTC (rev 5480) @@ -0,0 +1,65 @@ +from unittest import TestCase +from test import test_support + +class Bucket(object): + def __init__(self, value): + self.__value = value + def _get(self): + return self.__value + def _set(self, value): + assert self.__value == value, "Value changed!" + value = property(_get,_set) + +class PropBucket(object): + def __init__(self): + self.__dict__['_d'] = {} + def __getattr__(self, attr): + value = self._d.setdefault(attr, 0) + self._d[attr] = value + 1 + return Bucket(value) + def __setattr__(self, attr, value): + value.append(attr) + +class EvaluationOrder(TestCase): + def test_TestFunctionality(self): + bucket = PropBucket() + try: + bucket.prop.value = bucket.prop.value + 0 + except AssertionError: + pass + else: + assert False, "PropBucket is not working" + def test_augassign(self): + bucket = PropBucket() + bucket.prop.value += 0 + def test_AssignOrder(self): + bucket = PropBucket() + expected = ['one','two','three'] + result = [] + bucket.one = bucket.two = bucket.three = result + assert result == expected, "expected %s, got %s" % (expected, result) + def test_operands(self): + m = [(2,), (1,)].pop + assert m() + m() == (1,2), "faulty operand order" + def test_arguments(self): + def one(a,b,c,d,*extra): + return reduce(lambda r,x: r+x,extra,a+b+c+d) + m = list((x,) for x in xrange(100,0,-1)).pop + value = one(m(),m(),m(),m()) + assert value == (1,2,3,4), "simple call, got: %s " % (value,) + value = one(m(),m(),d=m(),c=m()) + assert value == (5,6,8,7), "call with keywords, got: %s" % (value,) + value = one(m(),m(),m(),m(),m(),m()) + assert value == (9,10,11,12,13,14), "long call, got: %s" % (value,) + value = one(m(),m(),*[m(),m(),m(),m()]) + assert value == (15,16,17,18,19,20), "varcalls, got: %s" % (value,) + value = one(m(),m(),**dict(c=m(),d=m())) + assert value == (21,22,23,24), "varkeywordcall, got: %s" % (value,) + value = one(*[m(),m()],**dict(c=m(),d=m())) + assert value == (25,26,27,28), "bothvarcalls, got: %s" % (value,) + +def test_main(): + test_support.run_unittest(EvaluationOrder) + +if __name__ == '__main__': + test_main() Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2008-10-20 06:29:50 UTC (rev 5479) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2008-10-20 11:13:38 UTC (rev 5480) @@ -457,13 +457,13 @@ visit(node.value); if (node.targets.length == 1) { set(node.targets[0]); - return null; + } else { + int tmp = storeTop(); + for (exprType target : node.targets) { + set(target, tmp); + } + code.freeLocal(tmp); } - int tmp = storeTop(); - for (int i=node.targets.length-1; i>=0; i--) { - set(node.targets[i], tmp); - } - code.freeLocal(tmp); return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-10-20 06:29:58
|
Revision: 5479 http://jython.svn.sourceforge.net/jython/?rev=5479&view=rev Author: cgroves Date: 2008-10-20 06:29:50 +0000 (Mon, 20 Oct 2008) Log Message: ----------- The pain of not having the generic inferring statics from Google collections finally got to the point where I felt the need to whip up version for Jython. Add Generic with static methods to make Lists, Maps and Sets that infer their generic types from the generics of whatever they're being assigned to. I went for brevity in naming the methods as I felt they'd be idiomatic enough in Jython to read well, but could be convinced that more descriptive names - newArrayList() instead of list() for example - would be better. Modified Paths: -------------- trunk/jython/src/org/python/compiler/AdapterMaker.java trunk/jython/src/org/python/compiler/ProxyMaker.java trunk/jython/src/org/python/core/BytecodeLoader.java trunk/jython/src/org/python/core/PyType.java trunk/jython/src/org/python/core/PyUnicode.java trunk/jython/src/org/python/expose/generate/ExposeTask.java trunk/jython/src/org/python/expose/generate/ExposedMethodFinder.java trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java trunk/jython/src/org/python/expose/generate/TypeExposer.java trunk/jython/src/org/python/modules/_functools/PyPartial.java trunk/jython/src/org/python/util/NameUnionAntType.java trunk/jython/src/org/python/util/jython.java Added Paths: ----------- trunk/jython/src/org/python/util/Generic.java Modified: trunk/jython/src/org/python/compiler/AdapterMaker.java =================================================================== --- trunk/jython/src/org/python/compiler/AdapterMaker.java 2008-10-20 02:03:44 UTC (rev 5478) +++ trunk/jython/src/org/python/compiler/AdapterMaker.java 2008-10-20 06:29:50 UTC (rev 5479) @@ -8,6 +8,7 @@ import org.python.objectweb.asm.Label; import org.python.objectweb.asm.Opcodes; +import org.python.util.Generic; public class AdapterMaker extends ProxyMaker @@ -17,7 +18,7 @@ } public void build() throws Exception { - names = new HashSet<String>(); + names = Generic.set(); int access = Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNCHRONIZED; classfile = new ClassFile(myClass, "java/lang/Object", access); Modified: trunk/jython/src/org/python/compiler/ProxyMaker.java =================================================================== --- trunk/jython/src/org/python/compiler/ProxyMaker.java 2008-10-20 02:03:44 UTC (rev 5478) +++ trunk/jython/src/org/python/compiler/ProxyMaker.java 2008-10-20 06:29:50 UTC (rev 5479) @@ -8,14 +8,13 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.util.HashMap; -import java.util.HashSet; import java.util.Map; import java.util.Set; import org.python.core.Py; import org.python.objectweb.asm.Label; import org.python.objectweb.asm.Opcodes; +import org.python.util.Generic; public class ProxyMaker implements ClassConstants, Opcodes { @@ -34,7 +33,7 @@ public static Map<Class<?>, Integer> types=fillTypes(); public static Map<Class<?>, Integer> fillTypes() { - Map<Class<?>, Integer> typeMap = new HashMap<Class<?>, Integer>(); + Map<Class<?>, Integer> typeMap = Generic.map(); typeMap.put(Boolean.TYPE, tBoolean); typeMap.put(Byte.TYPE, tByte); typeMap.put(Short.TYPE, tShort); @@ -57,7 +56,7 @@ Class<?> superclass; Class<?>[] interfaces; Set<String> names; - Set<String> supernames = new HashSet<String>(); + Set<String> supernames = Generic.set(); public ClassFile classfile; public String myClass; public boolean isAdapter=false; @@ -123,8 +122,8 @@ public static String makeSignature(Class<?>[] sig, Class<?> ret) { StringBuffer buf=new StringBuffer(); buf.append("("); - for (int i=0; i<sig.length; i++) { - buf.append(mapType(sig[i])); + for (Class<?> element : sig) { + buf.append(mapType(element)); } buf.append(")"); buf.append(mapType(ret)); @@ -315,7 +314,7 @@ Class<?>[] exceptions) throws Exception { Label start = null; Label end = null; - + String jcallName = "_jcall"; int instLocal = 0; @@ -374,7 +373,7 @@ boolean throwableFound = false; Label handlerStart = null; - for (int i = 0; i < exceptions.length; i++) { + for (Class<?> exception : exceptions) { handlerStart = new Label(); code.label(handlerStart); int excLocal = code.getLocal("java/lang/Throwable"); @@ -383,11 +382,11 @@ code.aload(excLocal); code.athrow(); - code.visitTryCatchBlock(start, end, handlerStart, mapClass(exceptions[i])); + code.visitTryCatchBlock(start, end, handlerStart, mapClass(exception)); doNullReturn(code, ret); code.freeLocal(excLocal); - if (exceptions[i] == Throwable.class) + if (exception == Throwable.class) throwableFound = true; } @@ -471,8 +470,8 @@ StringBuffer buf = new StringBuffer(m.getName()); buf.append(":"); Class<?>[] params = m.getParameterTypes(); - for (int i = 0; i < params.length; i++) { - buf.append(params[i].getName()); + for (Class<?> param : params) { + buf.append(param.getName()); buf.append(","); } return buf.toString(); @@ -480,8 +479,7 @@ protected void addMethods(Class<?> c, Set<String> t) throws Exception { Method[] methods = c.getDeclaredMethods(); - for (int i=0; i<methods.length; i++) { - Method method = methods[i]; + for (Method method : methods) { String s = methodString(method); if (t.contains(s)) continue; @@ -499,13 +497,13 @@ if (Modifier.isProtected(access)) { access = (access & ~Modifier.PROTECTED) | Modifier.PUBLIC; if (Modifier.isFinal(access)) { - addSuperMethod(methods[i], access); + addSuperMethod(method, access); continue; } } else if (Modifier.isFinal(access)) { continue; } - addMethod(methods[i], access); + addMethod(method, access); } Class<?> sc = c.getSuperclass(); @@ -513,8 +511,8 @@ addMethods(sc, t); Class<?>[] ifaces = c.getInterfaces(); - for (int j=0; j<ifaces.length; j++) { - addMethods(ifaces[j], t); + for (Class<?> iface : ifaces) { + addMethods(iface, t); } } @@ -530,15 +528,15 @@ public void addConstructors(Class<?> c) throws Exception { Constructor<?>[] constructors = c.getDeclaredConstructors(); String name = mapClass(c); - for (int i = 0; i < constructors.length; i++) { - int access = constructors[i].getModifiers(); + for (Constructor<?> constructor : constructors) { + int access = constructor.getModifiers(); if (Modifier.isPrivate(access)) continue; if (Modifier.isNative(access)) access = access & ~Modifier.NATIVE; if (Modifier.isProtected(access)) access = access & ~Modifier.PROTECTED | Modifier.PUBLIC; - Class<?>[] parameters = constructors[i].getParameterTypes(); + Class<?>[] parameters = constructor.getParameterTypes(); String sig = makeSignature(parameters, Void.TYPE); addConstructor(name, parameters, Void.TYPE, sig, access); } @@ -666,7 +664,7 @@ } public void build() throws Exception { - names = new HashSet<String>(); + names = Generic.set(); int access = superclass.getModifiers(); if ((access & Modifier.FINAL) != 0) { throw new InstantiationException("can't subclass final class"); @@ -678,17 +676,17 @@ addConstructors(superclass); classfile.addInterface("org/python/core/PyProxy"); - Set<String> seenmethods = new HashSet<String>(); + Set<String> seenmethods = Generic.set(); addMethods(superclass, seenmethods); - for (int i=0; i<interfaces.length; i++) { - if (interfaces[i].isAssignableFrom(superclass)) { + for (Class<?> iface : interfaces) { + if (iface.isAssignableFrom(superclass)) { Py.writeWarning("compiler", "discarding redundant interface: "+ - interfaces[i].getName()); + iface.getName()); continue; } - classfile.addInterface(mapClass(interfaces[i])); - addMethods(interfaces[i], seenmethods); + classfile.addInterface(mapClass(iface)); + addMethods(iface, seenmethods); } doConstants(); addClassDictInit(); Modified: trunk/jython/src/org/python/core/BytecodeLoader.java =================================================================== --- trunk/jython/src/org/python/core/BytecodeLoader.java 2008-10-20 02:03:44 UTC (rev 5478) +++ trunk/jython/src/org/python/core/BytecodeLoader.java 2008-10-20 06:29:50 UTC (rev 5479) @@ -2,10 +2,10 @@ package org.python.core; import java.security.SecureClassLoader; -import java.util.ArrayList; import java.util.List; import org.python.objectweb.asm.ClassReader; +import org.python.util.Generic; /** * Utility class for loading of compiled python modules and java classes defined in python modules. @@ -14,7 +14,7 @@ /** * Turn the java byte code in data into a java class. - * + * * @param name * the name of the class * @param data @@ -24,9 +24,9 @@ */ public static Class<?> makeClass(String name, byte[] data, Class<?>... referents) { Loader loader = new Loader(); - for (int i = 0; i < referents.length; i++) { + for (Class<?> referent : referents) { try { - ClassLoader cur = referents[i].getClassLoader(); + ClassLoader cur = referent.getClassLoader(); if (cur != null) { loader.addParent(cur); } @@ -37,7 +37,7 @@ /** * Turn the java byte code in data into a java class. - * + * * @param name * the name of the class * @param referents @@ -54,7 +54,7 @@ /** * Turn the java byte code for a compiled python module into a java class. - * + * * @param name * the name of the class * @param data @@ -73,7 +73,7 @@ public static class Loader extends SecureClassLoader { - private List<ClassLoader> parents = new ArrayList<ClassLoader>(); + private List<ClassLoader> parents = Generic.list(); public Loader() { parents.add(imp.getSyspathJavaLoader()); @@ -85,6 +85,7 @@ } } + @Override protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { Class<?> c = findLoadedClass(name); if (c != null) { Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2008-10-20 02:03:44 UTC (rev 5478) +++ trunk/jython/src/org/python/core/PyType.java 2008-10-20 06:29:50 UTC (rev 5479) @@ -8,12 +8,12 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import org.python.core.util.StringUtil; import org.python.expose.ExposeAsSuperclass; @@ -24,6 +24,7 @@ import org.python.expose.ExposedSet; import org.python.expose.ExposedType; import org.python.expose.TypeBuilder; +import org.python.util.Generic; /** * The Python Type object implementation. @@ -76,7 +77,7 @@ private int numSlots; private ReferenceQueue<PyType> subclasses_refq = new ReferenceQueue<PyType>(); - private HashSet<WeakReference<PyType>> subclasses = new HashSet<WeakReference<PyType>>(); + private Set<WeakReference<PyType>> subclasses = Generic.set(); private final static Class<?>[] O = {PyObject.class}; private final static Class<?>[] OO = {PyObject.class, PyObject.class}; @@ -548,7 +549,7 @@ PyObject[] savedBases = bases; PyType savedBase = base; PyObject[] savedMro = mro; - List<Object> savedSubMros = new ArrayList<Object>(); + List<Object> savedSubMros = Generic.list(); try { bases = newBases; base = newBase; @@ -695,7 +696,7 @@ } } - private static void fill_classic_mro(ArrayList<PyObject> acc, PyClass classic_cl) { + private static void fill_classic_mro(List<PyObject> acc, PyClass classic_cl) { if (!acc.contains(classic_cl)) { acc.add(classic_cl); } @@ -706,7 +707,7 @@ } private static PyObject[] classic_mro(PyClass classic_cl) { - ArrayList<PyObject> acc = new ArrayList<PyObject>(); + List<PyObject> acc = Generic.list(); fill_classic_mro(acc, classic_cl); return acc.toArray(new PyObject[acc.size()]); } @@ -785,7 +786,7 @@ to_merge[n] = bases; remain[n] = 0; - ArrayList<PyObject> acc = new ArrayList<PyObject>(); + List<PyObject> acc = Generic.list(); acc.add(this); int empty_cnt = 0; @@ -1050,7 +1051,7 @@ public static void addBuilder(Class<?> forClass, TypeBuilder builder) { if (classToBuilder == null) { - classToBuilder = new HashMap<Class<?>, TypeBuilder>(); + classToBuilder = Generic.map(); } classToBuilder.put(forClass, builder); @@ -1099,7 +1100,7 @@ public static synchronized PyType fromClass(Class<?> c) { if (class_to_type == null) { - class_to_type = new HashMap<Class<?>, PyType>(); + class_to_type = Generic.map(); addFromClass(PyType.class); } PyType type = class_to_type.get(c); Modified: trunk/jython/src/org/python/core/PyUnicode.java =================================================================== --- trunk/jython/src/org/python/core/PyUnicode.java 2008-10-20 02:03:44 UTC (rev 5478) +++ trunk/jython/src/org/python/core/PyUnicode.java 2008-10-20 06:29:50 UTC (rev 5479) @@ -1,18 +1,18 @@ package org.python.core; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + import org.python.expose.ExposedMethod; import org.python.expose.ExposedNew; import org.python.expose.ExposedType; import org.python.expose.MethodType; import org.python.modules._codecs; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; +import org.python.util.Generic; /** * a builtin python unicode string. @@ -39,9 +39,9 @@ public PyUnicode(String string, boolean isBasic) { this(TYPE, string); - plane = isBasic ? Plane.BASIC : Plane.UNKNOWN; + plane = isBasic ? Plane.BASIC : Plane.UNKNOWN; } - + public PyUnicode(PyType subtype, String string) { super(subtype, string); } @@ -77,7 +77,7 @@ } return buffer; } - + PyUnicode(Iterator<Integer> iter) { this(fromCodePoints(iter)); } @@ -96,18 +96,18 @@ } return codePoints; } - + // modified to know something about codepoints; we just need to return the // corresponding substring; darn UTF16! // TODO: we could avoid doing this unnecessary copy @Override public String substring(int start, int end) { if (isBasicPlane()) { - return super.substring(start, end); + return super.substring(start, end); } return new PyUnicode(newSubsequenceIterator(start, end, 1)).string; } - + /** * Creates a PyUnicode from an already interned String. Just means it won't * be reinterned if used in a place that requires interned Strings. @@ -132,9 +132,9 @@ // public boolean isBasicPlane() { // return false; // } - + // END RETAIN - + public int getCodePointCount() { if (codePointCount >= 0) { return codePointCount; @@ -201,7 +201,7 @@ protected PyString createInstance(String str, boolean isBasic) { return new PyUnicode(str, isBasic); } - + @Override public PyObject __mod__(PyObject other) { return unicode___mod__(other); @@ -304,7 +304,6 @@ while (i > 0) { int W1 = string.charAt(k); if (W1 >= 0xD800 && W1 < 0xDC00) { - int W2 = string.charAt(k + 1); k += 2; } else { k += 1; @@ -524,7 +523,7 @@ public StripIterator(PyUnicode sep, Iterator<Integer> iter) { this.iter = iter; if (sep != null) { - Set<Integer> sepSet = new HashSet<Integer>(); + Set<Integer> sepSet = Generic.set(); for (Iterator<Integer> sepIter = sep.newSubsequenceIterator(); sepIter.hasNext();) { sepSet.add(sepIter.next()); } @@ -732,7 +731,7 @@ private class ReversedIterator<T> implements Iterator { - private final List<T> reversed = new ArrayList<T>(); + private final List<T> reversed = Generic.list(); private final Iterator<T> iter; ReversedIterator(Iterator<T> iter) { @@ -807,7 +806,7 @@ super(maxsplit); this.sep = sep; } - + public PyUnicode next() { StringBuilder buffer = new StringBuilder(); @@ -857,7 +856,7 @@ return new SepSplitIterator(sep, maxsplit); } } - + @ExposedMethod final PyTuple unicode_rpartition(PyObject sep) { return unicodeRpartition(sep); @@ -882,7 +881,7 @@ return str_rsplit(null, maxsplit); } } - + @ExposedMethod(defaults = "false") final PyList unicode_splitlines(boolean keepends) { if (isBasicPlane()) { @@ -957,8 +956,8 @@ throw Py.TypeError(function + "() argument 2 must be char, not str"); } return fillchar.codePointAt(0); - } - + } + @ExposedMethod(defaults="null") final PyObject unicode_ljust(int width, String padding) { int n = width - getCodePointCount(); @@ -1065,20 +1064,20 @@ if (isBasicPlane() && newPiece.isBasicPlane() && oldPiece.isBasicPlane()) { return replace(oldPiece, newPiece, maxsplit); } - + StringBuilder buffer = new StringBuilder(); - + if (oldPiece.getCodePointCount() == 0) { Iterator<Integer> iter = newSubsequenceIterator(); for (int i = 1; (maxsplit == -1 || i < maxsplit) && iter.hasNext(); i++) { if (i == 1) { buffer.append(newPiece.string); } - buffer.appendCodePoint((Integer) iter.next()); + buffer.appendCodePoint(iter.next()); buffer.append(newPiece.string); } while (iter.hasNext()) { - buffer.appendCodePoint((Integer) iter.next()); + buffer.appendCodePoint(iter.next()); } return new PyUnicode(buffer); } else { @@ -1311,7 +1310,7 @@ public Iterator<Integer> iterator() { return newSubsequenceIterator(); } - + @ExposedMethod final String unicode_toString() { return toString(); Modified: trunk/jython/src/org/python/expose/generate/ExposeTask.java =================================================================== --- trunk/jython/src/org/python/expose/generate/ExposeTask.java 2008-10-20 02:03:44 UTC (rev 5478) +++ trunk/jython/src/org/python/expose/generate/ExposeTask.java 2008-10-20 06:29:50 UTC (rev 5479) @@ -4,7 +4,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.util.HashSet; import java.util.Set; import org.apache.tools.ant.BuildException; @@ -13,6 +12,7 @@ import org.apache.tools.ant.util.GlobPatternMapper; import org.apache.tools.ant.util.SourceFileScanner; import org.python.objectweb.asm.ClassWriter; +import org.python.util.Generic; public class ExposeTask extends MatchingTask { @@ -20,7 +20,7 @@ private File destDir; - private Set<File> toExpose = new HashSet<File>(); + private Set<File> toExpose = Generic.set(); /** * Set the source directories to find the class files to be exposed. @@ -42,7 +42,7 @@ /** * Set the destination directory into which the Java source files should be compiled. - * + * * @param destDir * the destination director */ @@ -52,7 +52,7 @@ /** * Gets the destination directory into which the java source files should be compiled. - * + * * @return the destination directory */ public File getDestdir() { Modified: trunk/jython/src/org/python/expose/generate/ExposedMethodFinder.java =================================================================== --- trunk/jython/src/org/python/expose/generate/ExposedMethodFinder.java 2008-10-20 02:03:44 UTC (rev 5478) +++ trunk/jython/src/org/python/expose/generate/ExposedMethodFinder.java 2008-10-20 06:29:50 UTC (rev 5479) @@ -1,14 +1,14 @@ package org.python.expose.generate; -import java.util.ArrayList; import java.util.List; +import org.python.expose.MethodType; import org.python.objectweb.asm.AnnotationVisitor; import org.python.objectweb.asm.MethodAdapter; import org.python.objectweb.asm.MethodVisitor; import org.python.objectweb.asm.Opcodes; import org.python.objectweb.asm.Type; -import org.python.expose.MethodType; +import org.python.util.Generic; /** * Visits a method passing all calls through to its delegate. If an ExposedNew or ExposedMethod @@ -131,7 +131,7 @@ public abstract void handleResult(String[] result); - List<String> vals = new ArrayList<String>(); + List<String> vals = Generic.list(); } class ExposedMethodVisitor extends RestrictiveAnnotationVisitor { Modified: trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java =================================================================== --- trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java 2008-10-20 02:03:44 UTC (rev 5478) +++ trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java 2008-10-20 06:29:50 UTC (rev 5479) @@ -2,9 +2,7 @@ import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -19,6 +17,7 @@ import org.python.objectweb.asm.MethodVisitor; import org.python.objectweb.asm.Opcodes; import org.python.objectweb.asm.Type; +import org.python.util.Generic; /** * Processes the bytecode of a Java class that has the {@link ExposedType} annotation on it and @@ -26,9 +25,9 @@ */ public class ExposedTypeProcessor implements Opcodes, PyTypes { - private List<MethodExposer> methodExposers = new ArrayList<MethodExposer>(); + private List<MethodExposer> methodExposers = Generic.list(); - private Map<String, DescriptorExposer> descExposers = new HashMap<String, DescriptorExposer>(); + private Map<String, DescriptorExposer> descExposers = Generic.map(); private Exposer newExposer; @@ -276,7 +275,7 @@ @Override public void handleResult(ClassMethodExposer exposer) { methodExposers.add(exposer); - + } }; } Modified: trunk/jython/src/org/python/expose/generate/TypeExposer.java =================================================================== --- trunk/jython/src/org/python/expose/generate/TypeExposer.java 2008-10-20 02:03:44 UTC (rev 5478) +++ trunk/jython/src/org/python/expose/generate/TypeExposer.java 2008-10-20 06:29:50 UTC (rev 5479) @@ -1,14 +1,14 @@ package org.python.expose.generate; import java.util.Collection; -import java.util.HashSet; import java.util.Set; -import org.python.objectweb.asm.Type; import org.python.core.BytecodeLoader; import org.python.expose.BaseTypeBuilder; import org.python.expose.ExposedType; import org.python.expose.TypeBuilder; +import org.python.objectweb.asm.Type; +import org.python.util.Generic; /** * Generates a subclass of TypeBuilder to expose a class with the {@link ExposedType} annotation as @@ -42,7 +42,7 @@ this.name = name; this.methods = methods; this.descriptors = descriptors; - Set<String> names = new HashSet<String>(); + Set<String> names = Generic.set(); for(DescriptorExposer exposer : descriptors) { if(!names.add(exposer.getName())) { throwDupe(exposer.getName()); Modified: trunk/jython/src/org/python/modules/_functools/PyPartial.java =================================================================== --- trunk/jython/src/org/python/modules/_functools/PyPartial.java 2008-10-20 02:03:44 UTC (rev 5478) +++ trunk/jython/src/org/python/modules/_functools/PyPartial.java 2008-10-20 06:29:50 UTC (rev 5479) @@ -1,14 +1,12 @@ /* Copyright (c) Jython Developers */ package org.python.modules._functools; -import java.util.HashMap; import java.util.Map; import org.python.core.Py; import org.python.core.PyDictionary; import org.python.core.PyNewWrapper; import org.python.core.PyObject; -import org.python.core.PyString; import org.python.core.PyStringMap; import org.python.core.PyTuple; import org.python.core.PyType; @@ -17,6 +15,7 @@ import org.python.expose.ExposedNew; import org.python.expose.ExposedSet; import org.python.expose.ExposedType; +import org.python.util.Generic; @ExposedType(name = "_functools.partial") public class PyPartial extends PyObject { @@ -93,7 +92,7 @@ kwAppl = this.keywords; } else { // first merge keywords to determine the keyword count - HashMap<String, PyObject> merged = new HashMap<String, PyObject>(); + Map<String, PyObject> merged = Generic.map(); int i; for (i = 0; i < this.keywords.length; i++) { String keyword = this.keywords[i]; @@ -149,12 +148,14 @@ return kwDict; } + @Override @ExposedGet(name = "__dict__") public PyObject getDict() { ensureDict(); return __dict__; } + @Override @ExposedSet(name = "__dict__") public void setDict(PyObject val) { if (!(val instanceof PyStringMap) && !(val instanceof PyDictionary)) { Added: trunk/jython/src/org/python/util/Generic.java =================================================================== --- trunk/jython/src/org/python/util/Generic.java (rev 0) +++ trunk/jython/src/org/python/util/Generic.java 2008-10-20 06:29:50 UTC (rev 5479) @@ -0,0 +1,37 @@ +package org.python.util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * Static methods to make instances of collections with their generic types inferred from what + * they're being assigned to. The idea is stolen from <code>Sets</code>, <code>Lists</code> and + * <code>Maps</code> from <a href="http://code.google.com/p/google-collections/">Google + * Collections</a>. + */ +public class Generic { + /** + * Makes a List with its generic type inferred from whatever its being assigned to. + */ + public static <T> List<T> list() { + return new ArrayList<T>(); + } + + /** + * Makes a Map using generic types inferred from whatever this is being assigned to. + */ + public static <K, V> Map<K, V> map() { + return new HashMap<K, V>(); + } + + /** + * Makes a Set using the generic type inferred from whatever this is being assigned to. + */ + public static <T> Set<T> set() { + return new HashSet<T>(); + } +} Modified: trunk/jython/src/org/python/util/NameUnionAntType.java =================================================================== --- trunk/jython/src/org/python/util/NameUnionAntType.java 2008-10-20 02:03:44 UTC (rev 5478) +++ trunk/jython/src/org/python/util/NameUnionAntType.java 2008-10-20 06:29:50 UTC (rev 5479) @@ -20,7 +20,7 @@ protected Collection<Resource> getCollection() { List<ResourceCollection> collections = getResourceCollections(); // preserve order-encountered using a list; keep track of the items with a set - Set<String> seenNames = new HashSet<String>(); + Set<String> seenNames = Generic.set(); List<Resource> union = new ArrayList(); for (ResourceCollection rc : collections) { for (Iterator<Resource> resources = rc.iterator(); resources.hasNext();) { Modified: trunk/jython/src/org/python/util/jython.java =================================================================== --- trunk/jython/src/org/python/util/jython.java 2008-10-20 02:03:44 UTC (rev 5478) +++ trunk/jython/src/org/python/util/jython.java 2008-10-20 06:29:50 UTC (rev 5479) @@ -6,8 +6,6 @@ import java.io.FileInputStream; import java.io.InputStream; import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -32,10 +30,10 @@ private static final String COPYRIGHT = "Type \"help\", \"copyright\", \"credits\" or \"license\" for more information."; - static final String usageHeader = + static final String usageHeader = "usage: jython [option] ... [-c cmd | -m mod | file | -] [arg] ...\n"; - private static final String usage = usageHeader + + private static final String usage = usageHeader + "Options and arguments:\n" + //(and corresponding environment variables):\n" + "-c cmd : program passed in as string (terminates option list)\n" + //"-d : debug output from parser (also PYTHONDEBUG=x)\n" + @@ -84,15 +82,15 @@ throw Py.ValueError("jar file missing '__run__.py'"); PyStringMap locals = new PyStringMap(); - - // Stripping the stuff before the last File.separator fixes Bug - // #931129 by keeping illegal characters out of the generated - // proxy class name + + // Stripping the stuff before the last File.separator fixes Bug + // #931129 by keeping illegal characters out of the generated + // proxy class name int beginIndex; if ((beginIndex = filename.lastIndexOf(File.separator)) != -1) { filename = filename.substring(beginIndex + 1); } - + locals.__setitem__("__name__", new PyString(filename)); locals.__setitem__("zipfile", Py.java2py(zip)); @@ -153,7 +151,7 @@ systemState.ps1 = systemState.ps2 = new PyString(); } } - + // Print banner and copyright information (or not) if (opts.interactive && opts.notice && !opts.runModule) { System.err.println(InteractiveConsole.getDefaultBanner()); @@ -331,13 +329,13 @@ { public String filename; public boolean jar, interactive, notice; - public boolean runModule; + public boolean runModule; public boolean fixInteractive; public boolean help, version; public String[] argv; public java.util.Properties properties; public String command; - public List<String> warnoptions = new ArrayList<String>(); + public List<String> warnoptions = Generic.list(); public String encoding; public String division; public String moduleName; @@ -455,7 +453,7 @@ interactive = false; } - index++; + index++; int n = args.length-index+1; argv = new String[n]; argv[0] = moduleName; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-10-20 02:03:52
|
Revision: 5478 http://jython.svn.sourceforge.net/jython/?rev=5478&view=rev Author: cgroves Date: 2008-10-20 02:03:44 +0000 (Mon, 20 Oct 2008) Log Message: ----------- Cleanup, modernization Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java trunk/jython/src/org/python/core/PyObject.java trunk/jython/src/org/python/core/PyType.java Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2008-10-20 01:41:32 UTC (rev 5477) +++ trunk/jython/src/org/python/core/Py.java 2008-10-20 02:03:44 UTC (rev 5478) @@ -5,6 +5,7 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; import java.io.ObjectStreamException; import java.io.OutputStream; @@ -19,12 +20,12 @@ import java.util.HashSet; import java.util.Set; +import org.python.antlr.ast.modType; import org.python.compiler.Module; import org.python.core.adapter.ClassicPyObjectAdapter; import org.python.core.adapter.ExtensiblePyObjectAdapter; import org.python.core.util.StringUtil; import org.python.modules.errno; -import org.python.antlr.ast.modType; public final class Py { @@ -80,7 +81,7 @@ public static PyString Space; /** Set if the type object is dynamically allocated */ public static long TPFLAGS_HEAPTYPE; - + /** Builtin types that are used to setup PyObject. */ static final Set<Class> BOOTSTRAP_TYPES = new HashSet<Class>(4); static { @@ -353,7 +354,7 @@ public static void FutureWarning(String message) { warning(FutureWarning, message); } - + public static PyObject ImportWarning; public static void ImportWarning(String message) { warning(ImportWarning, message); @@ -569,17 +570,17 @@ } static PyObject newUnicode(int codepoint) { - return (PyUnicode) makeCharacter(codepoint, true); + return makeCharacter(codepoint, true); } public static PyUnicode newUnicode(String s) { return new PyUnicode(s); } - + public static PyUnicode newUnicode(String s, boolean isBasic) { return new PyUnicode(s, isBasic); } - + public static PyBoolean newBoolean(boolean t) { return t ? Py.True : Py.False; } @@ -752,7 +753,7 @@ // Pre-initialize the PyJavaClass for OutOfMemoryError so when we need // it it creating the pieces for it won't cause an additional out of // memory error. Fix for bug #1654484 - PyJavaClass.lookup(java.lang.OutOfMemoryError.class); + PyJavaClass.lookup(OutOfMemoryError.class); } public static PySystemState defaultSystemState; // This is a hack to get initializations to work in proper order @@ -889,11 +890,11 @@ } instance.__init__(pargs, Py.NoKeywords); } - + /** * Initializes a default PythonInterpreter and runs the code from * {@link PyRunnable#getMain} as __main__ - * + * * Called by the code generated in {@link Module#addMain()} */ public static void runMain(PyRunnable main, String[] args) throws Exception { @@ -1136,14 +1137,14 @@ // java.io.IOExceptions. This is a hack for 1.0.x until I can do // it right in 1.1 if (exc == Py.IOError) { - if (__builtin__.isinstance(pye.value, PyJavaClass.lookup(java.io.IOException.class))) { + if (__builtin__.isinstance(pye.value, PyJavaClass.lookup(IOException.class))) { return true; } } // FIXME too, same approach for OutOfMemoryError if (exc == Py.MemoryError) { if (__builtin__.isinstance(pye.value, - PyJavaClass.lookup(java.lang.OutOfMemoryError.class))) { + PyJavaClass.lookup(OutOfMemoryError.class))) { return true; } } @@ -1226,7 +1227,7 @@ } Py.runCode(code, locals, globals); } - + private final static ThreadStateMapping threadStateMapping = new ThreadStateMapping(); public static final ThreadState getThreadState() { @@ -1464,7 +1465,7 @@ /** * Uses the PyObjectAdapter passed to {@link PySystemState#initialize} to turn o into a PyObject. - * + * * @see ClassicPyObjectAdapter - default PyObjectAdapter type */ public static PyObject java2py(Object o) { @@ -1483,7 +1484,7 @@ /** * Set the ExtensiblePyObjectAdapter used by java2py. - * + * * @param adapter The new ExtensiblePyObjectAdapter */ protected static void setAdapter(ExtensiblePyObjectAdapter adapter) { @@ -1530,7 +1531,7 @@ /** * Create a new Python class. - * + * * @param name the String name of the class * @param bases an array of PyObject base classes * @param dict the class's namespace, containing the class body @@ -1677,8 +1678,8 @@ } return Py.compile_flags(node, getName(), filename, true, printResults, cflags); } - - public static PyObject compile_flags(modType node, String filename, + + public static PyObject compile_flags(modType node, String filename, String kind, CompilerFlags cflags) { boolean printResults = false; if (kind.equals("single")) { @@ -1686,16 +1687,16 @@ } return Py.compile_flags(node, getName(), filename, true, printResults, cflags); } - + public static PyObject compile_flags(String data, String filename, String kind, CompilerFlags cflags) { - + if (data.contains("\0")) { throw Py.TypeError("compile() expected string without null bytes"); } - + byte[] bytes; if (cflags != null && cflags.dont_imply_dedent) { bytes = StringUtil.toBytes(data + "\n"); @@ -1894,7 +1895,7 @@ return abstract_issubclass(icls, cls); } } - + public static boolean isSubClass(PyObject derived,PyObject cls) { return isSubClass(derived, cls, 0); } Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2008-10-20 01:41:32 UTC (rev 5477) +++ trunk/jython/src/org/python/core/PyObject.java 2008-10-20 02:03:44 UTC (rev 5478) @@ -21,18 +21,18 @@ */ @ExposedType(name = "object") public class PyObject implements Serializable { - + public static final PyType TYPE = PyType.fromClass(PyObject.class); - + @ExposedNew @ExposedMethod final void object___init__(PyObject[] args, String[] keywords) { -// XXX: attempted fix for object(foo=1), etc -// XXX: this doesn't work for metaclasses, for some reason +// XXX: attempted fix for object(foo=1), etc +// XXX: this doesn't work for metaclasses, for some reason // if (args.length > 0) { // throw Py.TypeError("default __new__ takes no parameters"); // } - + } private PyType objtype; @@ -77,16 +77,17 @@ this.objtype = objtype; } - // A package private constructor used by PyJavaClass - // xxx will need variants for PyType of PyType and still PyJavaClass of PyJavaClass - PyObject(boolean dummy) { - objtype = (PyType) this; + /** + * Creates the PyObject for the base type. The argument only exists to make the constructor + * distinct. + */ + PyObject(boolean ignored) { + objtype = (PyType)this; } /** - * The standard constructor for a <code>PyObject</code>. It will set - * the <code>objtype</code> field to correspond to the specific - * subclass of <code>PyObject</code> being instantiated. + * The standard constructor for a <code>PyObject</code>. It will set the <code>objtype</code> + * field to correspond to the specific subclass of <code>PyObject</code> being instantiated. **/ public PyObject() { objtype = PyType.fromClass(getClass()); @@ -145,7 +146,7 @@ public PyUnicode __unicode__() { return new PyUnicode(__str__()); } - + /** * Equivalent to the standard Python __hash__ method. This method can * not be overridden. Instead, you should override the standard Java @@ -342,13 +343,13 @@ if(keys == null) throw Py.TypeError(name + "argument after ** must be a mapping"); - for (int i = 0; i < keywords.length; i++) - if (kwargs.__finditem__(keywords[i]) != null) + for (String keyword : keywords) + if (kwargs.__finditem__(keyword) != null) throw Py.TypeError( name + "got multiple values for " + "keyword argument '" - + keywords[i] + + keyword + "'"); argslen += kwargs.__len__(); } @@ -648,21 +649,21 @@ * <p> * If a PyObject subclass should support iteration based in the __finditem__() method, it must * supply an implementation of __iter__() like this: - * + * * <pre> * public PyObject __iter__() { * return new PySequenceIter(this); * } * </pre> - * + * * When iterating over a python sequence from java code, it should be done with code like this: - * + * * <pre> * for (PyObject item : seq.asIterable()) { * // Do somting with item * } * </pre> - * + * * @since 2.2 */ public PyObject __iter__() { @@ -729,13 +730,13 @@ * Very similar to the standard Python __getattr__ method. Instead of * throwing a AttributeError if the item isn't found, this just returns * null. - * + * * By default, this method will call * <code>__findattr__(name.internedString)</code> with the appropriate - * args. - * + * args. + * * @param name the name to lookup in this namespace - * + * * @return the value corresponding to name or null if name is not found */ public final PyObject __findattr__(PyString name) { @@ -748,7 +749,7 @@ /** * A variant of the __findattr__ method which accepts a Java * <code>String</code> as the name. - * + * * <b>Warning: name must be an interned string!</b> * * @param name the name to lookup in this namespace @@ -763,22 +764,22 @@ return null; } throw exc; - } + } } - + /** - * Attribute lookup hook. If the attribute is not found, null may be - * returned or a Py.AttributeError can be thrown, whatever is more + * Attribute lookup hook. If the attribute is not found, null may be + * returned or a Py.AttributeError can be thrown, whatever is more * correct, efficient and/or convenient for the implementing class. - * - * Client code should use {@link #__getattr__(String)} or - * {@link #__findattr__(String)}. Both methods have a clear policy for - * failed lookups. - * - * @return The looked up value. May return null if the attribute is not found + * + * Client code should use {@link #__getattr__(String)} or + * {@link #__findattr__(String)}. Both methods have a clear policy for + * failed lookups. + * + * @return The looked up value. May return null if the attribute is not found * @throws PyException(AttributeError) if the attribute is not found. This - * is not mandatory, null can be returned if it fits the implementation - * better, or for performance reasons. + * is not mandatory, null can be returned if it fits the implementation + * better, or for performance reasons. */ public PyObject __findattr_ex__(String name) { return object___findattr__(name); @@ -789,7 +790,7 @@ * * By default, this method will call * <code>__getattr__(name.internedString)</code> with the appropriate - * args. + * args. * * @param name the name to lookup in this namespace * @return the value corresponding to name @@ -1002,9 +1003,9 @@ * * This method can not be overridden. * To implement __coerce__ functionality, override __coerce_ex__ instead. - * - * Also, <b>do not</b> call this method from exposed 'coerce' methods. - * Instead, Use adaptToCoerceTuple over the result of the overriden + * + * Also, <b>do not</b> call this method from exposed 'coerce' methods. + * Instead, Use adaptToCoerceTuple over the result of the overriden * __coerce_ex__. * * @param pyo the other object involved in the coercion. @@ -1022,13 +1023,13 @@ /** * Adapts the result of __coerce_ex__ to a tuple of two elements, with the - * resulting coerced values, or to Py.NotImplemented, if o is Py.None. - * - * This is safe to be used from subclasses exposing '__coerce__' + * resulting coerced values, or to Py.NotImplemented, if o is Py.None. + * + * This is safe to be used from subclasses exposing '__coerce__' * (as opposed to {@link #__coerce__(PyObject)}, which calls the virtual * method {@link #__coerce_ex__(PyObject)}) - * - * @param o either a PyObject[2] or a PyObject, as given by + * + * @param o either a PyObject[2] or a PyObject, as given by * {@link #__coerce_ex__(PyObject)}. */ protected final PyObject adaptToCoerceTuple(Object o) { @@ -1292,7 +1293,7 @@ PyObject token = null; PyType t1 = this.getType(); PyType t2 = o.getType(); - + if (t1 != t2 && t2.isSubType(t1)) { return o._eq(this); } @@ -1331,7 +1332,7 @@ PyObject token = null; PyType t1 = this.getType(); PyType t2 = o.getType(); - + if (t1 != t2 && t2.isSubType(t1)) { return o._ne(this); } @@ -1365,7 +1366,7 @@ PyObject token = null; PyType t1 = this.getType(); PyType t2 = o.getType(); - + if (t1 != t2 && t2.isSubType(t1)) { return o._ge(this); } @@ -1399,7 +1400,7 @@ PyObject token = null; PyType t1 = this.getType(); PyType t2 = o.getType(); - + if (t1 != t2 && t2.isSubType(t1)) { return o._gt(this); } @@ -1433,7 +1434,7 @@ PyObject token = null; PyType t1 = this.getType(); PyType t2 = o.getType(); - + if (t1 != t2 && t2.isSubType(t1)) { return o._le(this); } @@ -1467,7 +1468,7 @@ PyObject token = null; PyType t1 = this.getType(); PyType t2 = o.getType(); - + if (t1 != t2 && t2.isSubType(t1)) { return o._lt(this); } @@ -1678,7 +1679,7 @@ throw Py.TypeError(String.format("'%.200s' object cannot be interpreted as an index", getType().fastGetName())); } - + /** * @param op the String form of the op (e.g. "+") * @param o2 the right operand @@ -1705,7 +1706,7 @@ protected String unsupportedopMessage(String op, PyObject o2) { return null; } - + /** * Should return an error message suitable for substitution where. * @@ -3523,7 +3524,7 @@ // backward comp impls. /** * Get descriptor for this PyObject. - * + * * @param obj - * the instance accessing this descriptor. Can be null if this is * being accessed by a type. @@ -3544,7 +3545,7 @@ public void __delete__(PyObject obj) { throw Py.AttributeError("object internal __delete__ impl is abstract"); } - + @ExposedMethod final PyObject object___getattribute__(PyObject arg0) { String name = asName(arg0); @@ -3553,7 +3554,7 @@ noAttributeError(name); return ret; } - + // name must be interned final PyObject object___findattr__(String name) { @@ -3581,12 +3582,12 @@ return null; } - + @ExposedMethod final void object___setattr__(PyObject name, PyObject value) { object___setattr__(asName(name), value); } - + private final void object___setattr__(String name, PyObject value) { PyObject descr = objtype.lookup(name); @@ -3616,7 +3617,7 @@ noAttributeError(name); } - + @ExposedMethod final void object___delattr__(PyObject name) { object___delattr__(asName(name)); @@ -3684,7 +3685,7 @@ /** Used for pickling. If the subclass specifies __reduce__, it will * override __reduce_ex__ in the base-class, even if __reduce_ex__ was * called with an argument. - * + * * @param arg PyInteger specifying reduce algorithm (method without this * argument defaults to 0). * @return a tuple of (class, tuple) @@ -3853,7 +3854,7 @@ throw new ConversionException(index); } - // TODO - remove when all generated users are migrated to @Exposed and asInt() + // TODO - remove when all generated users are migrated to @Exposed and asInt() public int asInt(int index) throws ConversionException { throw new ConversionException(index); } Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2008-10-20 01:41:32 UTC (rev 5477) +++ trunk/jython/src/org/python/core/PyType.java 2008-10-20 02:03:44 UTC (rev 5478) @@ -27,7 +27,6 @@ /** * The Python Type object implementation. - * */ @ExposedType(name = "type") public class PyType extends PyObject implements Serializable { @@ -54,7 +53,7 @@ private long tp_flags; /** The underlying java class or null. */ - private Class underlying_class; + private Class<?> underlying_class; /** Whether it's a builtin type. */ boolean builtin = false; @@ -79,20 +78,23 @@ private ReferenceQueue<PyType> subclasses_refq = new ReferenceQueue<PyType>(); private HashSet<WeakReference<PyType>> subclasses = new HashSet<WeakReference<PyType>>(); - private final static Class[] O = {PyObject.class}; - private final static Class[] OO = {PyObject.class, PyObject.class}; + private final static Class<?>[] O = {PyObject.class}; + private final static Class<?>[] OO = {PyObject.class, PyObject.class}; /** Mapping of Java classes to their PyTypes. */ - private static HashMap<Class, PyType> class_to_type; + private static Map<Class<?>, PyType> class_to_type; /** Mapping of Java classes to their TypeBuilders. */ - private static HashMap<Class, TypeBuilder> classToBuilder; + private static Map<Class<?>, TypeBuilder> classToBuilder; - private PyType() { - } + private PyType() {} - private PyType(boolean dummy) { - super(true); + /** + * Creates the PyType instance for type itself. The argument just exists to make the constructor + * distinct. + */ + private PyType(boolean ignored) { + super(ignored); } PyType(PyType subtype) { @@ -288,7 +290,7 @@ return newobj; } - private static void fillFromClass(PyType newtype, String name, Class c, Class base, + private static void fillFromClass(PyType newtype, String name, Class<?> c, Class<?> base, TypeBuilder tb) { if (base == null) { base = c.getSuperclass(); @@ -333,7 +335,7 @@ newtype.dict = dict; } - private static void fillInClassic(Class c, Class<?> base, PyObject dict) { + private static void fillInClassic(Class<?> c, Class<?> base, PyObject dict) { if (Py.BOOTSTRAP_TYPES.contains(c)) { // BOOTSTRAP_TYPES will be filled in by addBuilder later return; @@ -341,7 +343,7 @@ Map<String, Object> propnames = new HashMap<String, Object>(); Method[] methods = c.getMethods(); for (Method meth : methods) { - Class declaring = meth.getDeclaringClass(); + Class<?> declaring = meth.getDeclaringClass(); if (declaring != base && base.isAssignableFrom(declaring) && !ignore(meth)) { String methname = meth.getName(); String nmethname = normalize_name(methname); @@ -377,11 +379,11 @@ } Field[] fields = c.getFields(); for (Field field : fields) { - Class declaring = field.getDeclaringClass(); + Class<?> declaring = field.getDeclaringClass(); if (declaring != base && base.isAssignableFrom(declaring)) { String fldname = field.getName(); int fldmods = field.getModifiers(); - Class fldtype = field.getType(); + Class<?> fldtype = field.getType(); if (Modifier.isStatic(fldmods)) { if (fldname.startsWith("__doc__") && fldname.length() > 7 && fldtype == PyString.class) { @@ -409,7 +411,7 @@ } Method getter = null; Method setter = null; - Class proptype = null; + Class<?> proptype = null; getter = get_non_static_method(c, "get" + propname, new Class[] {}); if (getter == null) getter = get_non_static_method(c, "is" + propname, new Class[] {}); @@ -430,10 +432,10 @@ // XXX error } } - Constructor[] ctrs = c.getConstructors(); + Constructor<?>[] ctrs = c.getConstructors(); if (ctrs.length != 0) { final PyReflectedConstructor reflctr = new PyReflectedConstructor("_new_impl"); - for (Constructor ctr : ctrs) { + for (Constructor<?> ctr : ctrs) { reflctr.addConstructor(ctr); } PyObject new_ = new PyNewWrapper(c, "__new__", -1, -1) { @@ -446,16 +448,15 @@ } if (ClassDictInit.class.isAssignableFrom(c) && c != ClassDictInit.class) { try { - @SuppressWarnings("unchecked") Method m = c.getMethod("classDictInit", PyObject.class); - m.invoke(null, new Object[] {dict}); + m.invoke(null, dict); } catch (Exception exc) { throw error(exc); } } } - private static void fillInMRO(PyType type, Class base) { + private static void fillInMRO(PyType type, Class<?> base) { PyType[] mro; if (base == Object.class) { mro = new PyType[] {type}; @@ -564,7 +565,7 @@ } } } catch (PyException t) { - for (Iterator it = savedSubMros.iterator(); it.hasNext();) { + for (Iterator<Object> it = savedSubMros.iterator(); it.hasNext();) { PyType subtype = (PyType)it.next(); PyObject[] subtypeSavedMro = (PyObject[])it.next(); subtype.mro = subtypeSavedMro; @@ -633,7 +634,7 @@ } private void cleanup_subclasses() { - Reference ref; + Reference<?> ref; while ((ref = subclasses_refq.poll()) != null) { subclasses.remove(ref); } @@ -1017,7 +1018,7 @@ return Py.JavaError(e); } - private static Method get_non_static_method(Class<?> c, String name, Class[] parmtypes) { + private static Method get_non_static_method(Class<?> c, String name, Class<?>[] parmtypes) { try { Method meth = c.getMethod(name, parmtypes); if (!Modifier.isStatic(meth.getModifiers())) { @@ -1029,7 +1030,7 @@ return null; } - private static Method get_descr_method(Class c, String name, Class[] parmtypes) { + private static Method get_descr_method(Class<?> c, String name, Class<?>[] parmtypes) { Method meth = get_non_static_method(c, name, parmtypes); if (meth != null && meth.getDeclaringClass() != PyObject.class) { return meth; @@ -1038,8 +1039,8 @@ } private static boolean ignore(Method meth) { - Class[] exceptions = meth.getExceptionTypes(); - for (Class exception : exceptions) { + Class<?>[] exceptions = meth.getExceptionTypes(); + for (Class<?> exception : exceptions) { if (exception == PyIgnoreMethodTag.class) { return true; } @@ -1047,9 +1048,9 @@ return false; } - public static void addBuilder(Class forClass, TypeBuilder builder) { + public static void addBuilder(Class<?> forClass, TypeBuilder builder) { if (classToBuilder == null) { - classToBuilder = new HashMap<Class, TypeBuilder>(); + classToBuilder = new HashMap<Class<?>, TypeBuilder>(); } classToBuilder.put(forClass, builder); @@ -1063,7 +1064,7 @@ PyType objType = fromClass(builder.getTypeClass()); objType.name = builder.getName(); objType.dict = builder.getDict(objType); - Class base = builder.getBase(); + Class<?> base = builder.getBase(); if (base == Object.class) { base = forClass.getSuperclass(); } @@ -1072,13 +1073,13 @@ } } - private static PyType addFromClass(Class c) { + private static PyType addFromClass(Class<?> c) { if (ExposeAsSuperclass.class.isAssignableFrom(c)) { PyType exposedAs = fromClass(c.getSuperclass()); class_to_type.put(c, exposedAs); return exposedAs; } - Class base = null; + Class<?> base = null; String name = null; TypeBuilder tb = classToBuilder == null ? null : classToBuilder.get(c); if (tb != null) { @@ -1089,16 +1090,16 @@ } PyType newtype = class_to_type.get(c); if (newtype == null) { - newtype = c == PyType.class ? new PyType(true) : new PyType(); + newtype = c == PyType.class ? new PyType(false) : new PyType(); class_to_type.put(c, newtype); fillFromClass(newtype, name, c, base, tb); } return newtype; } - public static synchronized PyType fromClass(Class c) { + public static synchronized PyType fromClass(Class<?> c) { if (class_to_type == null) { - class_to_type = new HashMap<Class, PyType>(); + class_to_type = new HashMap<Class<?>, PyType>(); addFromClass(PyType.class); } PyType type = class_to_type.get(c); @@ -1333,7 +1334,7 @@ return doc; } - public Object __tojava__(Class c) { + public Object __tojava__(Class<?> c) { if (underlying_class != null && (c == Object.class || c == Class.class || c == Serializable.class)) { return underlying_class; @@ -1429,19 +1430,20 @@ return new TypeResolver(underlying_class, getModule().toString(), name); } - public static interface Newstyle { - } + private interface OnType { - private interface OnType { boolean onType(PyType type); } static class TypeResolver implements Serializable { - private Class underlying_class; - private String module; + + private Class<?> underlying_class; + + String module; + private String name; - TypeResolver(Class underlying_class, String module, String name) { + TypeResolver(Class<?> underlying_class, String module, String name) { this.underlying_class = underlying_class; this.module = module; this.name = name; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-10-20 01:41:40
|
Revision: 5477 http://jython.svn.sourceforge.net/jython/?rev=5477&view=rev Author: cgroves Date: 2008-10-20 01:41:32 +0000 (Mon, 20 Oct 2008) Log Message: ----------- Move BaseTypeBuilder out of TypeExposer so the compile time bits of the exposing system can be excluded from jython.jar Modified Paths: -------------- trunk/jython/build.xml trunk/jython/src/org/python/expose/generate/TypeExposer.java Added Paths: ----------- trunk/jython/src/org/python/expose/BaseTypeBuilder.java Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2008-10-20 01:40:25 UTC (rev 5476) +++ trunk/jython/build.xml 2008-10-20 01:41:32 UTC (rev 5477) @@ -558,7 +558,7 @@ <jar destfile="${dist.dir}/jython.jar" duplicate="fail"> <nameunion> <fileset dir="${exposed.dir}"/> - <fileset dir="${compile.dir}"/> + <fileset dir="${compile.dir}" excludes="org/python/expose/generate/**"/> </nameunion> <fileset dir="${jarjar.dir}"> <include name="org/python/objectweb/asm/ClassReader.class" /> Added: trunk/jython/src/org/python/expose/BaseTypeBuilder.java =================================================================== --- trunk/jython/src/org/python/expose/BaseTypeBuilder.java (rev 0) +++ trunk/jython/src/org/python/expose/BaseTypeBuilder.java 2008-10-20 01:41:32 UTC (rev 5477) @@ -0,0 +1,67 @@ +package org.python.expose; + +import org.python.core.PyBuiltinMethod; +import org.python.core.PyDataDescr; +import org.python.core.PyMethodDescr; +import org.python.core.PyNewWrapper; +import org.python.core.PyObject; +import org.python.core.PyStringMap; +import org.python.core.PyType; + +public class BaseTypeBuilder implements TypeBuilder { + + private PyNewWrapper newWrapper; + + private PyBuiltinMethod[] meths; + + private PyDataDescr[] descrs; + + private Class typeClass; + + private Class baseClass; + + private String name; + + public BaseTypeBuilder(String name, + Class typeClass, + Class baseClass, + PyBuiltinMethod[] meths, + PyDataDescr[] descrs, + PyNewWrapper newWrapper) { + this.typeClass = typeClass; + this.baseClass = baseClass; + this.name = name; + this.descrs = descrs; + this.meths = meths; + this.newWrapper = newWrapper; + } + + public PyObject getDict(PyType type) { + PyObject dict = new PyStringMap(); + for(PyBuiltinMethod func : meths) { + PyMethodDescr pmd = func.makeDescriptor(type); + dict.__setitem__(pmd.getName(), pmd); + } + for(PyDataDescr descr : descrs) { + descr.setType(type); + dict.__setitem__(descr.getName(), descr); + } + if(newWrapper != null) { + dict.__setitem__("__new__", newWrapper); + newWrapper.setWrappedType(type); + } + return dict; + } + + public String getName() { + return name; + } + + public Class getTypeClass() { + return typeClass; + } + + public Class getBase() { + return baseClass; + } +} \ No newline at end of file Modified: trunk/jython/src/org/python/expose/generate/TypeExposer.java =================================================================== --- trunk/jython/src/org/python/expose/generate/TypeExposer.java 2008-10-20 01:40:25 UTC (rev 5476) +++ trunk/jython/src/org/python/expose/generate/TypeExposer.java 2008-10-20 01:41:32 UTC (rev 5477) @@ -6,13 +6,7 @@ import org.python.objectweb.asm.Type; import org.python.core.BytecodeLoader; -import org.python.core.PyBuiltinMethod; -import org.python.core.PyDataDescr; -import org.python.core.PyMethodDescr; -import org.python.core.PyNewWrapper; -import org.python.core.PyObject; -import org.python.core.PyStringMap; -import org.python.core.PyType; +import org.python.expose.BaseTypeBuilder; import org.python.expose.ExposedType; import org.python.expose.TypeBuilder; @@ -144,62 +138,4 @@ superConstructor(STRING, CLASS, CLASS, ABUILTIN_METHOD, ADATA_DESCR, PYNEWWRAPPER); endConstructor(); } - - protected static class BaseTypeBuilder implements TypeBuilder { - - private PyNewWrapper newWrapper; - - private PyBuiltinMethod[] meths; - - private PyDataDescr[] descrs; - - private Class typeClass; - - private Class baseClass; - - private String name; - - public BaseTypeBuilder(String name, - Class typeClass, - Class baseClass, - PyBuiltinMethod[] meths, - PyDataDescr[] descrs, - PyNewWrapper newWrapper) { - this.typeClass = typeClass; - this.baseClass = baseClass; - this.name = name; - this.descrs = descrs; - this.meths = meths; - this.newWrapper = newWrapper; - } - - public PyObject getDict(PyType type) { - PyObject dict = new PyStringMap(); - for(PyBuiltinMethod func : meths) { - PyMethodDescr pmd = func.makeDescriptor(type); - dict.__setitem__(pmd.getName(), pmd); - } - for(PyDataDescr descr : descrs) { - descr.setType(type); - dict.__setitem__(descr.getName(), descr); - } - if(newWrapper != null) { - dict.__setitem__("__new__", newWrapper); - newWrapper.setWrappedType(type); - } - return dict; - } - - public String getName() { - return name; - } - - public Class getTypeClass() { - return typeClass; - } - - public Class getBase() { - return baseClass; - } - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-10-20 01:40:30
|
Revision: 5476 http://jython.svn.sourceforge.net/jython/?rev=5476&view=rev Author: cgroves Date: 2008-10-20 01:40:25 +0000 (Mon, 20 Oct 2008) Log Message: ----------- Remove newcompiler since it's not being used now and it's going to be replaced by the advanced compiler Removed Paths: ------------- trunk/jython/src/org/python/newcompiler/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |