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: <cg...@us...> - 2008-12-12 06:13:59
|
Revision: 5747 http://jython.svn.sourceforge.net/jython/?rev=5747&view=rev Author: cgroves Date: 2008-12-12 06:13:55 +0000 (Fri, 12 Dec 2008) Log Message: ----------- Tested by test_java_integration.AutoSuperTest Removed Paths: ------------- trunk/jython/bugtests/test086.py Deleted: trunk/jython/bugtests/test086.py =================================================================== --- trunk/jython/bugtests/test086.py 2008-12-12 06:12:39 UTC (rev 5746) +++ trunk/jython/bugtests/test086.py 2008-12-12 06:13:55 UTC (rev 5747) @@ -1,18 +0,0 @@ -""" -Check autocreate of java superclass. -""" - -import support - -import java - -class mythread(java.lang.Thread): - def __init__( self, name="bla" ): - self.name = name - def run( self ): - pass - -mythread().start() -mythread("pipo 1").start() -mythread("pipo 2").start() - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-12 06:12:43
|
Revision: 5746 http://jython.svn.sourceforge.net/jython/?rev=5746&view=rev Author: cgroves Date: 2008-12-12 06:12:39 +0000 (Fri, 12 Dec 2008) Log Message: ----------- Tested by test_java_visibility.test_java_subclass Removed Paths: ------------- trunk/jython/bugtests/classes/test084j1.java trunk/jython/bugtests/classes/test084j2.java trunk/jython/bugtests/classes/test084j3.java trunk/jython/bugtests/test084.py Deleted: trunk/jython/bugtests/classes/test084j1.java =================================================================== --- trunk/jython/bugtests/classes/test084j1.java 2008-12-12 06:11:35 UTC (rev 5745) +++ trunk/jython/bugtests/classes/test084j1.java 2008-12-12 06:12:39 UTC (rev 5746) @@ -1,13 +0,0 @@ - -public class test084j1 { - public test084j1() { - } - - public static String main(String argv[]) { - return " I'm test084j1"; - } - - public static String ohMy() { - return " I really am test084j1"; - } -} Deleted: trunk/jython/bugtests/classes/test084j2.java =================================================================== --- trunk/jython/bugtests/classes/test084j2.java 2008-12-12 06:11:35 UTC (rev 5745) +++ trunk/jython/bugtests/classes/test084j2.java 2008-12-12 06:12:39 UTC (rev 5746) @@ -1,5 +0,0 @@ - -public class test084j2 extends test084j1 { - public test084j2() { - } -} \ No newline at end of file Deleted: trunk/jython/bugtests/classes/test084j3.java =================================================================== --- trunk/jython/bugtests/classes/test084j3.java 2008-12-12 06:11:35 UTC (rev 5745) +++ trunk/jython/bugtests/classes/test084j3.java 2008-12-12 06:12:39 UTC (rev 5746) @@ -1,12 +0,0 @@ -public class test084j3 extends test084j2 { - public test084j3() { - } - - public static String main( String args[] ) { - return " I'm test084j3"; - } - - public static String ohMy() { - return " I really am test084j3"; - } -} Deleted: trunk/jython/bugtests/test084.py =================================================================== --- trunk/jython/bugtests/test084.py 2008-12-12 06:11:35 UTC (rev 5745) +++ trunk/jython/bugtests/test084.py 2008-12-12 06:12:39 UTC (rev 5746) @@ -1,15 +0,0 @@ -""" -Calling static methods in subclass. -""" - -import support - -support.compileJava("classes/test084j3.java") - -import test084j3 - -r = test084j3.main(["xxx"]) -support.compare(r, "test084j3") - -r = test084j3.ohMy() -support.compare(r, "test084j3") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-12 06:11:40
|
Revision: 5745 http://jython.svn.sourceforge.net/jython/?rev=5745&view=rev Author: cgroves Date: 2008-12-12 06:11:35 +0000 (Fri, 12 Dec 2008) Log Message: ----------- Tested by test_java_integration.AbstractOnSyspathTest Removed Paths: ------------- trunk/jython/bugtests/test083.py trunk/jython/bugtests/test083j1.java Deleted: trunk/jython/bugtests/test083.py =================================================================== --- trunk/jython/bugtests/test083.py 2008-12-12 06:11:03 UTC (rev 5744) +++ trunk/jython/bugtests/test083.py 2008-12-12 06:11:35 UTC (rev 5745) @@ -1,13 +0,0 @@ -""" -Test proxy maker from sys.path. CLASSPATH must *not* include "." in this test. -""" - -import support - -support.compileJava("test083j1.java") - -import test083j1 - -class A(test083j1): - pass - Deleted: trunk/jython/bugtests/test083j1.java =================================================================== --- trunk/jython/bugtests/test083j1.java 2008-12-12 06:11:03 UTC (rev 5744) +++ trunk/jython/bugtests/test083j1.java 2008-12-12 06:11:35 UTC (rev 5745) @@ -1,5 +0,0 @@ - -public interface test083j1 { - public void spam(); -} - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-12 06:11:08
|
Revision: 5744 http://jython.svn.sourceforge.net/jython/?rev=5744&view=rev Author: cgroves Date: 2008-12-12 06:11:03 +0000 (Fri, 12 Dec 2008) Log Message: ----------- Move interface test to test_java_integration and add interface overloading test Modified Paths: -------------- trunk/jython/Lib/test/test_java_integration.py Added Paths: ----------- trunk/jython/tests/java/org/python/tests/Callbacker.java Removed Paths: ------------- trunk/jython/bugtests/classes/test082j1.java trunk/jython/bugtests/classes/test082j2.java trunk/jython/bugtests/test082.py Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2008-12-12 05:40:12 UTC (rev 5743) +++ trunk/jython/Lib/test/test_java_integration.py 2008-12-12 06:11:03 UTC (rev 5744) @@ -387,6 +387,22 @@ self.assertEquals(s, "Foo!!!", "toString not overridden in interface") + def test_java_calling_python_interface_implementation(self): + from org.python.tests import Callbacker + called = [] + class PyCallback(Callbacker.Callback): + def call(self, extraarg=None): + called.append(extraarg) + Callbacker.callNoArg(PyCallback()) + Callbacker.callOneArg(PyCallback(), "arg") + self.assertEquals(None, called[0]) + self.assertEquals("arg", called[1]) + class PyBadCallback(Callbacker.Callback): + def call(pyself, extraarg): + self.fail("Shouldn't be callable with a no args") + self.assertRaises(TypeError, Callbacker.callNoArg, PyBadCallback()) + + class JavaStringTest(unittest.TestCase): def test_string_not_iterable(self): Deleted: trunk/jython/bugtests/classes/test082j1.java =================================================================== --- trunk/jython/bugtests/classes/test082j1.java 2008-12-12 05:40:12 UTC (rev 5743) +++ trunk/jython/bugtests/classes/test082j1.java 2008-12-12 06:11:03 UTC (rev 5744) @@ -1,6 +0,0 @@ - -public interface test082j1 { - public void doit( String dowhat ); - public void dosomethingelse( String dowhat ); -} - Deleted: trunk/jython/bugtests/classes/test082j2.java =================================================================== --- trunk/jython/bugtests/classes/test082j2.java 2008-12-12 05:40:12 UTC (rev 5743) +++ trunk/jython/bugtests/classes/test082j2.java 2008-12-12 06:11:03 UTC (rev 5744) @@ -1,7 +0,0 @@ - -public class test082j2 { - public static void doDoit( test082j1 callback ){ - callback.doit( "foo" ); - } -} - Deleted: trunk/jython/bugtests/test082.py =================================================================== --- trunk/jython/bugtests/test082.py 2008-12-12 05:40:12 UTC (rev 5743) +++ trunk/jython/bugtests/test082.py 2008-12-12 06:11:03 UTC (rev 5744) @@ -1,21 +0,0 @@ -""" -Passing an python implemented interface to a java method. -""" - -import support - -support.compileJava("classes/test082j1.java") -support.compileJava("classes/test082j2.java") - -import test082j1, test082j2 - -class pydoit( test082j1 ): - def doit( a, b): # too many arguments for interface - pass - - def dosomethingelse( a ): - pass - - -test082j2().doDoit( pydoit() ) - Added: trunk/jython/tests/java/org/python/tests/Callbacker.java =================================================================== --- trunk/jython/tests/java/org/python/tests/Callbacker.java (rev 0) +++ trunk/jython/tests/java/org/python/tests/Callbacker.java 2008-12-12 06:11:03 UTC (rev 5744) @@ -0,0 +1,19 @@ +package org.python.tests; + +public class Callbacker { + + public interface Callback { + + public void call(); + + public void call(String oneArg); + } + + public static void callNoArg(Callback c) { + c.call(); + } + + public static void callOneArg(Callback c, String arg) { + c.call(arg); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-12 05:40:18
|
Revision: 5743 http://jython.svn.sourceforge.net/jython/?rev=5743&view=rev Author: cgroves Date: 2008-12-12 05:40:12 +0000 (Fri, 12 Dec 2008) Log Message: ----------- Tested by test_java_integration.AbstractOnSyspathTest Removed Paths: ------------- trunk/jython/bugtests/test081.py trunk/jython/bugtests/test081j.java Deleted: trunk/jython/bugtests/test081.py =================================================================== --- trunk/jython/bugtests/test081.py 2008-12-12 05:22:18 UTC (rev 5742) +++ trunk/jython/bugtests/test081.py 2008-12-12 05:40:12 UTC (rev 5743) @@ -1,25 +0,0 @@ -""" -Try reloading a javaclass located on sys.path. -""" - -import support -import java -import sys - -def mkspam(a): - f = open("test081j.java", "w") - f.write(""" -public class test081j { - public static String spam() { return "%s"; } - public static void %s() {} -} -""" % (a, a)) - f.close() - support.compileJava("test081j.java") - - -mkspam("foo") - -import test081j -spam1 = test081j.spam() -support.compare(spam1, "foo") Deleted: trunk/jython/bugtests/test081j.java =================================================================== --- trunk/jython/bugtests/test081j.java 2008-12-12 05:22:18 UTC (rev 5742) +++ trunk/jython/bugtests/test081j.java 2008-12-12 05:40:12 UTC (rev 5743) @@ -1,5 +0,0 @@ - -public class test081j { - public static String spam() { return "foo"; } - public static void foo() {} -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-12 05:22:27
|
Revision: 5742 http://jython.svn.sourceforge.net/jython/?rev=5742&view=rev Author: cgroves Date: 2008-12-12 05:22:18 +0000 (Fri, 12 Dec 2008) Log Message: ----------- The test this was supporting was removed earlier Removed Paths: ------------- trunk/jython/bugtests/test080m.py Deleted: trunk/jython/bugtests/test080m.py =================================================================== --- trunk/jython/bugtests/test080m.py 2008-12-12 05:15:56 UTC (rev 5741) +++ trunk/jython/bugtests/test080m.py 2008-12-12 05:22:18 UTC (rev 5742) @@ -1 +0,0 @@ -def Spam(): return 'bar' \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-12 05:16:01
|
Revision: 5741 http://jython.svn.sourceforge.net/jython/?rev=5741&view=rev Author: cgroves Date: 2008-12-12 05:15:56 +0000 (Fri, 12 Dec 2008) Log Message: ----------- Removed merge tracking for "svnmerge" for https://jython.svn.sourceforge.net/svnroot/jython/branches/newstyle-java-types Property Changed: ---------------- trunk/jython/ Property changes on: trunk/jython ___________________________________________________________________ Modified: svnmerge-integrated - /branches/astwrite:1-5692 /branches/newstyle-java-types:1-5738 + /branches/astwrite:1-5692 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-12 05:14:53
|
Revision: 5740 http://jython.svn.sourceforge.net/jython/?rev=5740&view=rev Author: cgroves Date: 2008-12-12 05:14:49 +0000 (Fri, 12 Dec 2008) Log Message: ----------- Merged into trunk Removed Paths: ------------- branches/newstyle-java-types/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-12 03:57:45
|
Revision: 5739 http://jython.svn.sourceforge.net/jython/?rev=5739&view=rev Author: cgroves Date: 2008-12-12 03:57:33 +0000 (Fri, 12 Dec 2008) Log Message: ----------- Merged revisions 5564,5566-5567,5605,5607,5622-5623,5625,5631-5632,5650-5654,5656-5659,5662-5663,5666-5669,5673-5676,5688-5689,5692-5694,5698-5701,5705,5707-5711,5727-5729 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/branches/newstyle-java-types ........ r5564 | cgroves | 2008-11-09 19:31:53 -0800 (Sun, 09 Nov 2008) | 1 line Checkpoint of replacing PyJavaClass with PyJavaType. Works well enough that ProxyMaker creates PyObjects instead of PyJavaInstances and the interpreter starts up, but that's about it ........ r5566 | cgroves | 2008-11-09 19:56:44 -0800 (Sun, 09 Nov 2008) | 1 line Fill in Java inner classes ........ r5567 | cgroves | 2008-11-09 21:15:10 -0800 (Sun, 09 Nov 2008) | 1 line Implement the collection proxies as methods on PyJavaTypes ........ r5605 | cgroves | 2008-11-22 16:46:06 -0800 (Sat, 22 Nov 2008) | 1 line Use PyJavaType to initialize array, not PyJavaClass ........ r5607 | cgroves | 2008-11-22 18:36:05 -0800 (Sat, 22 Nov 2008) | 4 lines Rip out PyJavaClass and friends. This isn't even close to passing regrtest, but it runs well enough to start the interpreter and get through the first few. ........ r5622 | cgroves | 2008-11-23 15:12:46 -0800 (Sun, 23 Nov 2008) | 8 lines PyInstance ignored __tojava__ methods on its classes, so Java classes in the old world with a __tojava__ would be ignored as well. This differed from most other dunder methods, so the new PyJavaType exposes __tojava__ through PyObjectDerived. IOBase was using __tojava__ to mean something different than what PyObject was doing with it, so change the name to keep regular jython object conversion from picking up on it. ........ r5623 | cgroves | 2008-11-23 15:46:11 -0800 (Sun, 23 Nov 2008) | 1 line Create the java proxy object after __init__ runs if it wasn't created by __init__ ........ r5625 | cgroves | 2008-11-23 17:57:05 -0800 (Sun, 23 Nov 2008) | 1 line Don't strip the package out of wrapped Java types ........ r5631 | cgroves | 2008-11-23 21:37:21 -0800 (Sun, 23 Nov 2008) | 1 line Don't hork when exposing fields on an interface as it won't have a base class ........ r5632 | cgroves | 2008-11-23 21:52:36 -0800 (Sun, 23 Nov 2008) | 5 lines Reinstate the code from PyReflectedConstructor that redirectes to the proxy constructor whenever a Python subclass of a Java class attempts to call its Java-superclass constructor. PyJavaType can finally handle it. ........ r5650 | cgroves | 2008-11-28 00:12:30 -0800 (Fri, 28 Nov 2008) | 1 line Check for abstract classes and interfaces before attempting to auto-create a proxy ........ r5651 | cgroves | 2008-11-28 00:56:38 -0800 (Fri, 28 Nov 2008) | 8 lines Add an EQ_PROXY to PyJavaType to pass equals through to wrapped Java instances like PyJavaInstance did. Make PyBuiltinMethod Cloneable and use clone to implement a default bind implementation. This eliminates 75% of the crud that came with creating a builtin method in Java. ........ r5652 | cgroves | 2008-11-28 00:59:49 -0800 (Fri, 28 Nov 2008) | 1 line Whoops, didn't mean to remove Finn's copyright ........ r5653 | cgroves | 2008-11-28 01:13:19 -0800 (Fri, 28 Nov 2008) | 1 line PyObject needs to handle primitive conversion in the new world ........ r5654 | cgroves | 2008-11-28 02:06:54 -0800 (Fri, 28 Nov 2008) | 4 lines Expose static fields through PyBeanProperty if they share a name with the property. Instance fields supercede the propery. ........ r5656 | cgroves | 2008-11-28 13:29:14 -0800 (Fri, 28 Nov 2008) | 1 line Simplify PyBeanProperty construction ........ r5657 | cgroves | 2008-11-28 13:53:04 -0800 (Fri, 28 Nov 2008) | 1 line More cleanup ........ r5658 | cgroves | 2008-11-28 16:17:40 -0800 (Fri, 28 Nov 2008) | 12 lines Only attempt proxyInitting if __init__ has been found and worked, and only actually init instances of PyProxy. Add an __init__ for all Java classes, even interfaces and abstract classes. Handle throwing type errors for uninstantiable classes in PyReflectedConstructor. Pass _is and _isnot through to the javaproxy == if javaproxy is around. This assumes a constant mapping between a given Java type and the PyType wrapping it, but I think that's safe. ........ r5659 | cgroves | 2008-11-28 16:48:32 -0800 (Fri, 28 Nov 2008) | 9 lines Assign the type on PyBeanProperty to the type returned by its getter and only use a setter if its parameter's type matches that. Push accesses to PyObject.javaProxy that query information from the proxy through getJavaProxy. This calls proxyInit if the proxy doesn't already exist which keeps things from blowing up if something accesses the javaProxy in an __init__. ........ r5662 | cgroves | 2008-11-29 16:40:22 -0800 (Sat, 29 Nov 2008) | 6 lines Make java.lang.Object and Java interfaces descend from the Python object type. This changed the class initialization order, so put static constants in PyJavaType in a static method so they're actually initialized at time of use. ........ r5663 | cgroves | 2008-11-29 18:30:42 -0800 (Sat, 29 Nov 2008) | 1 line Hook bean events up in PyJavaType. All of test_java_integration passes again. ........ r5666 | cgroves | 2008-11-30 17:00:37 -0800 (Sun, 30 Nov 2008) | 7 lines Replace fillDict with init which encapsulates all the differences between PyType and PyJavaType initialization. Have bootstrap types use init as well to remove the duplication of type builder initialization. Include interfaces and superclasses in the mro of wrapped Java types. ........ r5667 | cgroves | 2008-11-30 17:06:33 -0800 (Sun, 30 Nov 2008) | 1 line PyReflectedFunction no longer exposes a String constructor ........ r5668 | cgroves | 2008-11-30 17:08:51 -0800 (Sun, 30 Nov 2008) | 1 line Go ahead and take multiple methods in PyReflectedFunction's constructor ........ r5669 | cgroves | 2008-11-30 17:14:21 -0800 (Sun, 30 Nov 2008) | 1 line Reset a PyJavaType's state when reload is called on it. This was just ignored on PyJavaClasses, so this is a little step up ........ r5673 | cgroves | 2008-12-01 21:23:26 -0800 (Mon, 01 Dec 2008) | 5 lines Changing the items in the dicts of loaded classes seemed to be confusing the exceptions module at least, so let's leave reloading Java classes a no-op until a later date. ........ r5674 | cgroves | 2008-12-01 23:46:14 -0800 (Mon, 01 Dec 2008) | 1 line Better error message for a bad version string, use the actual banner for checking ........ r5675 | cgroves | 2008-12-01 23:47:23 -0800 (Mon, 01 Dec 2008) | 3 lines Hook up container methods for Map separately as it isn't actually a Collection. ........ r5676 | cgroves | 2008-12-02 02:54:26 -0800 (Tue, 02 Dec 2008) | 4 lines Patch #1148 from Geoffrey French. Adds slice and negative index support to get, set and del methods on wrapped instances of java.util.List. ........ r5688 | cgroves | 2008-12-03 17:10:43 -0800 (Wed, 03 Dec 2008) | 8 lines Switch to using getJavaProxy() != null from getType() instanceof PyJavaType to detect if a PyObject is wrapping a Java object or a subclass of a Java object. This keeps PyObject subclasses from appearing to be proxy types. The old way was breaking copy as instances of classic classes - which have a type of PyJavaType by virtue of PyClass being a non-type subclass of PyObject - didn't have a Java proxy and were getting a different id with each call. ........ r5689 | cgroves | 2008-12-03 17:27:28 -0800 (Wed, 03 Dec 2008) | 1 line Only add inner classes to the dict of a Java type if there isn't already something with that name. Fixes test_cpickle ........ r5692 | cgroves | 2008-12-03 18:30:34 -0800 (Wed, 03 Dec 2008) | 7 lines Leave ExposedType annotations on processed types so they'll be visible at runtime. Use that to detect exposed inner classes in classes being loaded. Inner classes being loaded won't have set their builder in PyType yet, so they need to be added to BOOTSTRAP_TYPES so they're created as PyType instead of PyJavaType. ........ r5693 | cgroves | 2008-12-04 15:52:01 -0800 (Thu, 04 Dec 2008) | 1 line Expose __iter__ on Iterator in addition to Iterable and Map ........ r5694 | cgroves | 2008-12-04 16:26:54 -0800 (Thu, 04 Dec 2008) | 1 line Expose __hash__ on Object. I'm amazed at the number of things that passed without this ........ r5698 | cgroves | 2008-12-04 20:06:23 -0800 (Thu, 04 Dec 2008) | 1 line Get test_jy_internals passing again ........ r5699 | cgroves | 2008-12-05 01:06:12 -0800 (Fri, 05 Dec 2008) | 1 line Don't worry about the count, just assert the things that should and shouldn't be visible ........ r5700 | cgroves | 2008-12-05 03:21:55 -0800 (Fri, 05 Dec 2008) | 5 lines Make methods from superclasses and superinterfaces of private, protected or package protected classes call through their parent versions. Fixes blowups with a package protected implementation of attributes in sax. ........ r5701 | cgroves | 2008-12-05 03:38:02 -0800 (Fri, 05 Dec 2008) | 1 line Avoid non-public interface methods similarly to non-public class methods ........ r5705 | cgroves | 2008-12-05 18:35:31 -0800 (Fri, 05 Dec 2008) | 1 line Needs to be serializable for PySequence to be serializable ........ r5707 | cgroves | 2008-12-05 19:01:16 -0800 (Fri, 05 Dec 2008) | 1 line Tidying ........ r5708 | cgroves | 2008-12-05 19:23:28 -0800 (Fri, 05 Dec 2008) | 1 line Pull the proxy class directly out of the type. Fixes test_jser2 ........ r5709 | cgroves | 2008-12-05 20:19:46 -0800 (Fri, 05 Dec 2008) | 5 lines Add a target to run a single junit test from the tests directory. ant -Dtest=InterpreterTest singlejavatest will run just org.python.util.InterpreterTest and report to the console. ........ r5710 | cgroves | 2008-12-05 20:23:45 -0800 (Fri, 05 Dec 2008) | 6 lines Fix deserializing Jython objects while not in Python code. __builtin__.__import__ was changed to bail if Py.getFrame was null, but it can be called from Java code as in PyObjectInputStream, so it should just use PySystemState.builtins if it doesn't have a set of builtins from the frame. ........ r5711 | cgroves | 2008-12-05 21:18:08 -0800 (Fri, 05 Dec 2008) | 1 line Identify Java exceptions as exceptions ........ r5727 | cgroves | 2008-12-09 22:30:28 -0800 (Tue, 09 Dec 2008) | 1 line exceptions needs to extend PyObject to keep from being exposed as a descendent of Object ........ r5728 | cgroves | 2008-12-09 22:47:19 -0800 (Tue, 09 Dec 2008) | 4 lines Like exceptions, operator needs to extend PyObject to keep from picking up Object methods. Fixes test_richcmp. ........ r5729 | cgroves | 2008-12-09 23:09:49 -0800 (Tue, 09 Dec 2008) | 4 lines Allow setattr and delattr to access the dicts of PyJavaTypes. Fixes test_strptime as Time was expected to allow modification to its dict. ........ Modified Paths: -------------- trunk/jython/Lib/test/jser2_classes.py trunk/jython/Lib/test/test_array_jy.py trunk/jython/Lib/test/test_cmd_line.py trunk/jython/Lib/test/test_java_integration.py trunk/jython/Lib/test/test_java_visibility.py trunk/jython/Lib/test/test_joverload.py trunk/jython/Lib/test/test_jser2.py trunk/jython/Lib/test/test_jy_internals.py trunk/jython/build.xml trunk/jython/src/org/python/antlr/adapter/AliasAdapter.java trunk/jython/src/org/python/antlr/adapter/CmpopAdapter.java trunk/jython/src/org/python/antlr/adapter/ComprehensionAdapter.java trunk/jython/src/org/python/antlr/adapter/ExcepthandlerAdapter.java trunk/jython/src/org/python/antlr/adapter/ExprAdapter.java trunk/jython/src/org/python/antlr/adapter/IdentifierAdapter.java trunk/jython/src/org/python/antlr/adapter/KeywordAdapter.java trunk/jython/src/org/python/antlr/adapter/SliceAdapter.java trunk/jython/src/org/python/antlr/adapter/StmtAdapter.java trunk/jython/src/org/python/compiler/ProxyMaker.java trunk/jython/src/org/python/core/AstList.java trunk/jython/src/org/python/core/IdImpl.java trunk/jython/src/org/python/core/Options.java trunk/jython/src/org/python/core/Py.java trunk/jython/src/org/python/core/PyArray.java trunk/jython/src/org/python/core/PyArrayDerived.java trunk/jython/src/org/python/core/PyBaseExceptionDerived.java trunk/jython/src/org/python/core/PyBeanEvent.java trunk/jython/src/org/python/core/PyBeanEventProperty.java trunk/jython/src/org/python/core/PyBeanProperty.java trunk/jython/src/org/python/core/PyBooleanDerived.java trunk/jython/src/org/python/core/PyBuiltinCallable.java trunk/jython/src/org/python/core/PyBuiltinMethod.java trunk/jython/src/org/python/core/PyClass.java trunk/jython/src/org/python/core/PyClassMethodDerived.java trunk/jython/src/org/python/core/PyComplexDerived.java trunk/jython/src/org/python/core/PyCompoundCallable.java trunk/jython/src/org/python/core/PyDictionaryDerived.java trunk/jython/src/org/python/core/PyEnumerateDerived.java trunk/jython/src/org/python/core/PyException.java trunk/jython/src/org/python/core/PyFile.java trunk/jython/src/org/python/core/PyFileDerived.java trunk/jython/src/org/python/core/PyFloatDerived.java trunk/jython/src/org/python/core/PyFrozenSetDerived.java trunk/jython/src/org/python/core/PyInstance.java trunk/jython/src/org/python/core/PyIntegerDerived.java trunk/jython/src/org/python/core/PyJavaPackage.java trunk/jython/src/org/python/core/PyJavaType.java trunk/jython/src/org/python/core/PyList.java trunk/jython/src/org/python/core/PyListDerived.java trunk/jython/src/org/python/core/PyLongDerived.java trunk/jython/src/org/python/core/PyModuleDerived.java trunk/jython/src/org/python/core/PyObject.java trunk/jython/src/org/python/core/PyObjectDerived.java trunk/jython/src/org/python/core/PyPropertyDerived.java trunk/jython/src/org/python/core/PyProxy.java trunk/jython/src/org/python/core/PyReflectedConstructor.java trunk/jython/src/org/python/core/PyReflectedFunction.java trunk/jython/src/org/python/core/PySequence.java trunk/jython/src/org/python/core/PySetDerived.java trunk/jython/src/org/python/core/PySliceDerived.java trunk/jython/src/org/python/core/PyStringDerived.java trunk/jython/src/org/python/core/PySuperDerived.java trunk/jython/src/org/python/core/PyTupleDerived.java trunk/jython/src/org/python/core/PyType.java trunk/jython/src/org/python/core/PyTypeDerived.java trunk/jython/src/org/python/core/PyUnicodeDerived.java trunk/jython/src/org/python/core/StdoutWrapper.java trunk/jython/src/org/python/core/ThreadState.java trunk/jython/src/org/python/core/__builtin__.java trunk/jython/src/org/python/core/adapter/ClassicPyObjectAdapter.java trunk/jython/src/org/python/core/adapter/PyObjectAdapter.java trunk/jython/src/org/python/core/exceptions.java trunk/jython/src/org/python/core/imp.java trunk/jython/src/org/python/core/io/BufferedIOMixin.java trunk/jython/src/org/python/core/io/FileIO.java trunk/jython/src/org/python/core/io/IOBase.java trunk/jython/src/org/python/core/io/StreamIO.java trunk/jython/src/org/python/core/io/TextIOBase.java trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java trunk/jython/src/org/python/expose/generate/ExposedTypeVisitor.java trunk/jython/src/org/python/modules/_collections/PyDefaultDictDerived.java trunk/jython/src/org/python/modules/_collections/PyDequeDerived.java trunk/jython/src/org/python/modules/_csv/PyDialectDerived.java trunk/jython/src/org/python/modules/_functools/PyPartialDerived.java trunk/jython/src/org/python/modules/_hashlib.java trunk/jython/src/org/python/modules/_weakref/ReferenceTypeDerived.java trunk/jython/src/org/python/modules/cPickle.java trunk/jython/src/org/python/modules/cStringIO.java trunk/jython/src/org/python/modules/math.java trunk/jython/src/org/python/modules/operator.java trunk/jython/src/org/python/modules/random/PyRandomDerived.java trunk/jython/src/org/python/modules/thread/PyLocalDerived.java trunk/jython/src/org/python/modules/zipimport/zipimporterDerived.java trunk/jython/src/org/python/util/PythonObjectInputStream.java trunk/jython/src/templates/object.derived trunk/jython/tests/java/org/python/expose/generate/ExposedTypeVisitorTest.java trunk/jython/tests/java/org/python/util/InterpreterTest.java Added Paths: ----------- trunk/jython/Lib/test/test_java_list_delegate.py trunk/jython/src/org/python/core/SequenceIndexDelegate.java trunk/jython/tests/java/org/python/tests/InterfaceCombination.java trunk/jython/tests/java/org/python/tests/SerializationTest.java Removed Paths: ------------- trunk/jython/Lib/jreload.py trunk/jython/Lib/jxxload_help/ trunk/jython/Lib/test/test_jreload.py trunk/jython/src/org/python/core/AutoInternalTables.java trunk/jython/src/org/python/core/CollectionIter.java trunk/jython/src/org/python/core/CollectionProxy.java trunk/jython/src/org/python/core/InternalTables.java trunk/jython/src/org/python/core/PyJavaClass.java trunk/jython/src/org/python/core/PyJavaInnerClass.java trunk/jython/src/org/python/core/PyJavaInstance.java trunk/jython/src/org/python/core/SoftIInternalTables.java trunk/jython/src/org/python/core/WeakInternalTables.java trunk/jython/src/org/python/modules/_jython.java Property Changed: ---------------- trunk/jython/ trunk/jython/Lib/test/jser2_classes.py trunk/jython/Lib/test/test_jser2.py Property changes on: trunk/jython ___________________________________________________________________ Modified: svnmerge-integrated - /branches/astwrite:1-5692 /branches/newstyle-java-types:1-5563 + /branches/astwrite:1-5692 /branches/newstyle-java-types:1-5738 Added: svn:mergeinfo + /branches/newstyle-java-types:5564-5663,5666-5729 Deleted: trunk/jython/Lib/jreload.py =================================================================== --- trunk/jython/Lib/jreload.py 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/Lib/jreload.py 2008-12-12 03:57:33 UTC (rev 5739) @@ -1,119 +0,0 @@ -# java classes reload support (experimental) -# Copyright 2000 Samuele Pedroni - -# ?? could have problem with import pkg.jclass.inner (this should not be used in any case) -# ?? using import * with a load-set together with reloading can be confusing -# cannot be fixed => anyway import * is not for production code - -__version__ = "0.3" - -import sys -from org.python.core import imp,PyJavaPackage,PyJavaClass -from _jython import is_lazy as _is_lazy - -import jxxload_help - - -class _LoaderFactory(jxxload_help.JavaLoaderFactory): - def __init__(self,path): - vfs = jxxload_help.PathVFS() - for fname in path: - vfs.addVFS(fname) - self.vfs = vfs - - def makeLoader(self): - return jxxload_help.PathVFSJavaLoader(self.vfs,imp.getSyspathJavaLoader()) - -class _Unload: - - def __init__(self,ls): - self.ls = ls - self.ls_name = ls._name - self.loader = ls._mgr.loader - - def do_unload(self,pkg): - for n in pkg.__dict__.keys(): - e = pkg.__dict__[n] - if isinstance(e,PyJavaClass): - if _is_lazy(e): continue - if e.classLoader is self.loader: - del pkg.__dict__[n] - if pkg.__name__: - n = self.ls_name + '.' + pkg.__name__ + '.' +n - else: - n = self.ls_name + '.' + n - if sys.modules.has_key(n): del sys.modules[n] - - elif isinstance(e,PyJavaPackage): - self.do_unload(e) - - def __call__(self): - if self.loader: - if self.ls._mgr.checkLoader() is self.loader: - self.do_unload(self.ls._top) - self.ls._mgr.resetLoader() - loader = self.loader - jxxload_help.DiscardHelp.discard(loader,loader.interfaces) - self.loader = None - -class LoadSet: -# ?? for the moment from import * and dir do not work for LoadSet, but work for -# contained pkgs -# need java impl as PyObject - - def __init__(self,name,path): - mgr = jxxload_help.PackageManager(path,_LoaderFactory(path)) - self._name = name - self._mgr = mgr - self._top = mgr.topLevelPackage - - def __getattr__(self,name): - try: - return getattr(self._top,name) - except: - if name == 'unload': return _Unload(self) - raise - - - def __repr__(self): - return "<java load-set %s>" % self._name - -def unloadf(ls): - if not isinstance(ls,LoadSet): raise TypeError,"unloadf(): arg is not a load-set" - return _Unload(ls) - -def makeLoadSet(name,path): - if sys.modules.has_key(name): return sys.modules[name] - sys.modules[name] = ls = LoadSet(name,path) - return ls - -_reload = reload - -def _do_reload(ls_name,mgr,pkg): - pkg_name = pkg.__name__ - for n in pkg.__dict__.keys(): - e = pkg.__dict__[n] - if isinstance(e,PyJavaClass): - if _is_lazy(e): continue - del pkg.__dict__[n] - try : - c = mgr.findClass(pkg_name,n); - if c: - pkg.__dict__[n] = c - if pkg_name: - n = ls_name + '.' + pkg_name + '.' + n - else: - n = ls_name + '.' + n - if sys.modules.has_key(n): sys.modules[n] = c - except: - pass - elif isinstance(e,PyJavaPackage): - _do_reload(ls_name,mgr,e) - -def reload(ls): - if isinstance(ls,LoadSet): - ls._mgr.resetLoader() - _do_reload(ls._name,ls._mgr,ls._top) - return ls - else: - return _reload(ls) Modified: trunk/jython/Lib/test/jser2_classes.py =================================================================== (Binary files differ) Property changes on: trunk/jython/Lib/test/jser2_classes.py ___________________________________________________________________ Deleted: svn:mime-type - application/octet-stream Modified: trunk/jython/Lib/test/test_array_jy.py =================================================================== --- trunk/jython/Lib/test/test_array_jy.py 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/Lib/test/test_array_jy.py 2008-12-12 03:57:33 UTC (rev 5739) @@ -12,7 +12,7 @@ def test_jarray(self): # until it is fully formally removed - # While jarray is still being phased out, just flex the initilaizers. + # While jarray is still being phased out, just flex the initializers. # The rest of the test for array will catch all the big problems. import jarray jarray.array(range(5), 'i') @@ -23,7 +23,7 @@ def test_java_object_arrays(self): jStringArr = array(String, [String("a"), String("b"), String("c")]) self.assert_( - Arrays.equals(jStringArr.typecode, str(String)), + Arrays.equals(jStringArr.typecode, 'java.lang.String'), "String array typecode of wrong type, expected %s, found %s" % (jStringArr.typecode, str(String))) self.assertEqual(zeros(String, 5), Array.newInstance(String, 5)) Modified: trunk/jython/Lib/test/test_cmd_line.py =================================================================== --- trunk/jython/Lib/test/test_cmd_line.py 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/Lib/test/test_cmd_line.py 2008-12-12 03:57:33 UTC (rev 5739) @@ -45,8 +45,11 @@ self.assertTrue('usage' in self.start_python('-h')) def test_version(self): - version = 'Jython %d.%d' % sys.version_info[:2] - self.assertTrue(self.start_python('-V').startswith(version)) + from org.python.util import InteractiveConsole + expected = InteractiveConsole.getDefaultBanner() + reported = self.start_python('-V') + self.assertTrue(reported.startswith(expected), + "-V should start with '%s' but it printed '%s'" % (expected, reported)) def test_main(): test.test_support.run_unittest(CmdLineTest) Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/Lib/test/test_java_integration.py 2008-12-12 03:57:33 UTC (rev 5739) @@ -6,7 +6,7 @@ from test import test_support from java.awt import (Dimension, Component, Rectangle, Button, Color, HeadlessException) -from java.util import Vector, Hashtable +from java.util import ArrayList, Vector, HashMap, Hashtable from java.io import FileOutputStream, FileWriter, OutputStreamWriter from java.lang import Runnable, Thread, ThreadGroup, System, Runtime, Math, Byte @@ -55,9 +55,6 @@ A() class InstantiationTest(unittest.TestCase): - def test_cant_create_abstract(self): - self.assertRaises(TypeError, Component) - def test_can_subclass_abstract(self): class A(Component): pass @@ -339,8 +336,11 @@ class ColorTest(unittest.TestCase): def test_static_fields(self): - Color.red - Color.blue + self.assertEquals(Color(255, 0, 0), Color.RED) + # The bean accessor for getRed should be active on instances, but the static field red + # should be visible on the class + self.assertEquals(255, Color.red.red) + self.assertEquals(Color(0, 0, 255), Color.blue) def test_is_operator(self): red = Color.red @@ -363,7 +363,7 @@ y = BigDecimalTest().asBigDecimal() self.assertEqual(type(x), type(y), "BigDecimal coerced") - self.assertEqual(x, y, "BigDecimal coerced") + self.assertEqual(x, y, "coerced BigDecimal not equal to directly created version") class MethodInvTest(unittest.TestCase): @@ -394,6 +394,37 @@ x = lang.String('test') self.assertRaises(TypeError, list, x) +class JavaDelegationTest(unittest.TestCase): + def test_list_delegation(self): + for c in ArrayList, Vector: + a = c() + a.add("blah") + self.assertTrue("blah" in a) + self.assertEquals(1, len(a)) + n = 0 + for i in a: + n += 1 + self.assertEquals("blah", i) + self.assertEquals(1, n) + self.assertEquals("blah", a[0]) + a[0] = "bleh" + del a[0] + self.assertEquals(0, len(a)) + + def test_map_delegation(self): + m = HashMap() + m["a"] = "b" + self.assertTrue("a" in m) + self.assertEquals("b", m["a"]) + n = 0 + for k in m: + n += 1 + self.assertEquals("a", k) + self.assertEquals(1, n) + del m["a"] + self.assertEquals(0, len(m)) + + def test_main(): test_support.run_unittest(AbstractOnSyspathTest, InstantiationTest, @@ -414,6 +445,7 @@ MethodInvTest, InterfaceTest, JavaStringTest, + JavaDelegationTest, ) if __name__ == "__main__": Copied: trunk/jython/Lib/test/test_java_list_delegate.py (from rev 5729, branches/newstyle-java-types/Lib/test/test_java_list_delegate.py) =================================================================== --- trunk/jython/Lib/test/test_java_list_delegate.py (rev 0) +++ trunk/jython/Lib/test/test_java_list_delegate.py 2008-12-12 03:57:33 UTC (rev 5739) @@ -0,0 +1,181 @@ +from java.util import ArrayList, List, Vector + +from copy import copy + +import unittest +import test.test_support + +class CollectionProxyTest(unittest.TestCase): + def _perform_op(self, value, op_func): + """ + Perform an operation + + value - the value to operate on + op_func - the function that applies the operation to value + + Returns: + the result of calling op_func, OR the exception that was raised in op_func + """ + try: + return op_func(value) + except Exception, e: + return type(e) + + def check_list(self, control, results, initial): + for result in results: + try: + len(result) + except: + print result + self.assertEquals(len(control), len(result), "%s is wrong for %s" % (type(result), initial)) + for pvalue, jvalue in zip(control, result): + self.assertEquals(pvalue, jvalue) + + def _list_op_test(self, initial_value, op_func, check_value): + """ + Tests a list operation + + Ensures that performing an operation on: + - a python list + - a java.util.List instance + + givens the same result in both cases + """ + lists = [list(initial_value), ArrayList(initial_value), Vector(initial_value)] + + results = [self._perform_op(l, op_func) for l in lists] + self.check_list(lists[0], lists[1:], initial_value) + if check_value or not isinstance(results[0], list): + for r in results[1:]: + self.assertEquals(results[0], r) + else: + self.check_list(results[0], results[1:], initial_value) + + def test_get_integer(self): + initial_value = range(0, 5) + + for i in xrange(-7, 7): + self._list_op_test(initial_value, lambda xs: xs[i], True) + + def test_set_integer(self): + initial_value = range(0, 5) + + def make_op_func(index): + def _f(xs): + xs[index] = 100 + return _f + + for i in xrange(-7, 7): + self._list_op_test(initial_value, make_op_func(i), True) + + def test_set_slice(self): + initial_value = range(0, 10) + + def make_op_func(i, j, k, v): + def _f(xs): + xs[i:j:k] = v + return _f + + for i in xrange(-12, 12): + for j in xrange(-12, 12): + for k in xrange(-12, 12): + self._list_op_test(initial_value, make_op_func(i, j, k, []), True) + self._list_op_test(initial_value, make_op_func(i, j, k, range(0,2)), True) + self._list_op_test(initial_value, make_op_func(i, j, k, range(0,4)), True) + self._list_op_test(initial_value, make_op_func(i, j, k, xrange(0,2)), True) + + def test_del_integer(self): + initial_value = range(0,5) + + def make_op_func(index): + def _f(xs): + del xs[index] + return _f + + for i in xrange(-7, 7): + self._list_op_test(initial_value, make_op_func(i), True) + + def test_del_slice(self): + initial_value = range(0,10) + + def make_op_func(i, j, k): + def _f(xs): + del xs[i:j:k] + return _f + + for i in xrange(-12, 12): + for j in xrange(-12, 12): + for k in xrange(-12, 12): + self._list_op_test(initial_value, make_op_func(i, j, k), True) + + def test_len(self): + jlist = ArrayList() + jlist.addAll(range(0, 10)) + + self.assert_(len(jlist) == 10) + + def test_iter(self): + jlist = ArrayList() + jlist.addAll(range(0, 10)) + + i = iter(jlist) + + x = list(i) + + self.assert_(x == range(0, 10)) + + def test_override_len(self): + class MyList (ArrayList): + def __len__(self): + return self.size() + 1; + + m = MyList() + m.addAll(range(0,10)) + + self.assert_(len(m) == 11) + + def test_override_iter(self): + class MyList (ArrayList): + def __iter__(self): + return iter(self.subList(0, self.size() - 1)); + + + m = MyList() + m.addAll(range(0,10)) + i = iter(m) + x = list(i) + + self.assert_(x == range(0, 9)) + + def test_override_getsetdelitem(self): + # Create an ArrayList subclass that provides some silly overrides for get/set/del item + class MyList (ArrayList): + def __getitem__(self, key): + return self.get(key) * 2; + + def __setitem__(self, key, value): + return self.set(key, value * 2); + + def __delitem__(self, key): + self.add(84) + + + m = MyList() + m.addAll(range(0,10)) + + self.assert_(m[1] == 2) + self.assert_(m.get(1) == 1) + + m[0] = 3 + self.assert_(m.get(0) == 6) + self.assert_(m[0] == 12) + + del m[0] + self.assert_(m.size() == 11) + self.assert_(m.get(10) == 84) + +def test_main(): + test.test_support.run_unittest(CollectionProxyTest) + +if __name__ == "__main__": + test_main() Modified: trunk/jython/Lib/test/test_java_visibility.py =================================================================== --- trunk/jython/Lib/test/test_java_visibility.py 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/Lib/test/test_java_visibility.py 2008-12-12 03:57:33 UTC (rev 5739) @@ -1,11 +1,14 @@ import unittest from test import test_support -from org.python.tests import Invisible, SubVisible, Visible, VisibleOverride +from org.python.tests import InterfaceCombination, Invisible, SubVisible, Visible, VisibleOverride from org.python.tests import VisibilityResults as Results class VisibilityTest(unittest.TestCase): def test_invisible(self): - self.assertEquals([], dir(Invisible)) + for item in dir(Invisible): + self.assert_(not item.startswith("package")) + self.assert_(not item.startswith("private")) + self.assert_(not item.startswith("protected")) def test_protected_from_python_subclass(self): class SubVisible(Visible): @@ -22,8 +25,6 @@ self.assertEquals(Results.UNUSED, SubVisible(Results.UNUSED).visibleField) def test_visible(self): - self.assertEquals(5, len(dir(Visible))) - v = Visible() self.assertEquals(Results.PUBLIC_FIELD, v.visibleField) self.assertEquals(Results.PUBLIC_STATIC_FIELD, Visible.visibleStaticField) @@ -66,8 +67,21 @@ self.failUnless('visibleInstance' in c.__dict__, 'visibleInstance expected in %s __dict__' % c) + def test_interface_combination(self): + '''Checks that a private class that extends a public class and public interfaces has only the items + from the public bases visible''' + i = InterfaceCombination.newImplementation() + self.assertEquals(InterfaceCombination.NO_ARG_RESULT, i.getValue(), + "methods from IFace should be visible on Implementation") + self.assertEquals(InterfaceCombination.ONE_ARG_RESULT, i.getValue("one arg"), + "methods from IIFace should be visible on Implementation") + self.assertEquals(InterfaceCombination.TWO_ARG_RESULT, i.getValue("one arg", "two arg"), + "methods from Base should be visible on Implementation") + self.assertRaises(TypeError, i.getValue, "one arg", "two arg", "three arg", + "methods defined solely on Implementation shouldn't be visible") + self.assertFalse(hasattr(i, "internalMethod"), + "methods from private interfaces shouldn't be visible on a private class") - def test_main(): test_support.run_unittest(VisibilityTest) Modified: trunk/jython/Lib/test/test_joverload.py =================================================================== --- trunk/jython/Lib/test/test_joverload.py 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/Lib/test/test_joverload.py 2008-12-12 03:57:33 UTC (rev 5739) @@ -6,14 +6,12 @@ import unittest import java -import org.python.core +from org.python.core import PyReflectedFunction class PyReflFuncEnvl: def __init__(self,name,meths): - self.reflfunc = org.python.core.PyReflectedFunction(name) - for meth in meths: - self.reflfunc.addMethod(meth) + self.reflfunc = PyReflectedFunction(meths) def __call__(self,inst,args): return self.reflfunc(inst,*args) Deleted: trunk/jython/Lib/test/test_jreload.py =================================================================== --- trunk/jython/Lib/test/test_jreload.py 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/Lib/test/test_jreload.py 2008-12-12 03:57:33 UTC (rev 5739) @@ -1,33 +0,0 @@ -"""This test validates the fix for 511493 (jreload truncates large class files). - -We do this by loading a large class file Blob.class from blob.jar (source inside the jar). If the load failes with ClassFormatError, -the bug is present, if the load succeeds, the bug is fixed, if something else occurs, we don't know. -""" - -import unittest -from test import test_support - -from jreload import makeLoadSet -from java.lang import System, ClassFormatError - -import os - -class JreloadTestCase(unittest.TestCase): - - blobjar = test_support.findfile('blob.jar') - - def test( self ): - myls = makeLoadSet('myls', [self.blobjar]) - - try: - from myls import Blob - except ClassFormatError: - print "Reload Error is present" - raise - -def test_main(): - test_support.run_unittest(JreloadTestCase) - -if __name__ == "__main__": - test_main() - Modified: trunk/jython/Lib/test/test_jser2.py =================================================================== (Binary files differ) Property changes on: trunk/jython/Lib/test/test_jser2.py ___________________________________________________________________ Deleted: svn:mime-type - application/octet-stream Modified: trunk/jython/Lib/test/test_jy_internals.py =================================================================== --- trunk/jython/Lib/test/test_jy_internals.py 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/Lib/test/test_jy_internals.py 2008-12-12 03:57:33 UTC (rev 5739) @@ -60,7 +60,7 @@ iarr = java.lang.Object.getClass(self.e) sdv = java.lang.Class.getMethod(long, 'scaledDoubleValue', [iarr]) import org.python.core.PyReflectedFunction as ReflFunc - self.sdv = ReflFunc(sdv) + self.sdv = ReflFunc([sdv]) def test_basic_roundtrip(self): e = self.e Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/build.xml 2008-12-12 03:57:33 UTC (rev 5739) @@ -757,6 +757,16 @@ </target> <target name="test" depends="prepare-test,javatest,launchertest,regrtest"/> + <target name="singlejavatest" depends="compile,expose"> + <junit haltonfailure="true" fork="true"> + <formatter type="brief" usefile="false"/> + <sysproperty key="python.cachedir.skip" value="true"/> + <classpath refid="test.classpath"/> + <batchtest> + <fileset dir="${test.source.dir}" includes="**/${test}.java"/> + </batchtest> + </junit> + </target> <target name="prepare-test" depends="init"> <!-- Clean any old test output --> <delete dir="${junit.reports}"/> Modified: trunk/jython/src/org/python/antlr/adapter/AliasAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/AliasAdapter.java 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/src/org/python/antlr/adapter/AliasAdapter.java 2008-12-12 03:57:33 UTC (rev 5739) @@ -1,14 +1,12 @@ package org.python.antlr.adapter; -import org.python.core.Py; -import org.python.core.PyObject; -import org.python.core.PyJavaInstance; - -import org.python.antlr.ast.alias; - import java.util.ArrayList; import java.util.List; +import org.python.antlr.ast.alias; +import org.python.core.Py; +import org.python.core.PyObject; + public class AliasAdapter implements AstAdapter { public Object py2ast(PyObject o) { @@ -29,7 +27,7 @@ public List iter2ast(PyObject iter) { List<alias> aliases = new ArrayList<alias>(); for(Object o : (Iterable)iter) { - aliases.add((alias)py2ast((PyObject)(PyObject)o)); + aliases.add((alias)py2ast((PyObject)o)); } return aliases; } Modified: trunk/jython/src/org/python/antlr/adapter/CmpopAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/CmpopAdapter.java 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/src/org/python/antlr/adapter/CmpopAdapter.java 2008-12-12 03:57:33 UTC (rev 5739) @@ -1,28 +1,26 @@ package org.python.antlr.adapter; -import org.python.core.Py; -import org.python.core.PyObject; -import org.python.core.PyJavaInstance; +import java.util.ArrayList; +import java.util.List; import org.python.antlr.ast.cmpopType; import org.python.antlr.op.Eq; -import org.python.antlr.op.NotEq; -import org.python.antlr.op.Lt; -import org.python.antlr.op.LtE; import org.python.antlr.op.Gt; import org.python.antlr.op.GtE; +import org.python.antlr.op.In; import org.python.antlr.op.Is; import org.python.antlr.op.IsNot; -import org.python.antlr.op.In; +import org.python.antlr.op.Lt; +import org.python.antlr.op.LtE; +import org.python.antlr.op.NotEq; import org.python.antlr.op.NotIn; +import org.python.core.Py; +import org.python.core.PyObject; -import java.util.ArrayList; -import java.util.List; - public class CmpopAdapter implements AstAdapter { public Object py2ast(PyObject o) { - switch (((PyObject)o).asInt()) { + switch ((o).asInt()) { case 1: return cmpopType.Eq; case 2: @@ -53,23 +51,23 @@ switch ((cmpopType)o) { case Eq: return new Eq(); - case NotEq: + case NotEq: return new NotEq(); - case Lt: + case Lt: return new Lt(); - case LtE: + case LtE: return new LtE(); - case Gt: + case Gt: return new Gt(); - case GtE: + case GtE: return new GtE(); - case Is: + case Is: return new Is(); - case IsNot: + case IsNot: return new IsNot(); - case In: + case In: return new In(); - case NotIn: + case NotIn: return new NotIn(); } return Py.None; Modified: trunk/jython/src/org/python/antlr/adapter/ComprehensionAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/ComprehensionAdapter.java 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/src/org/python/antlr/adapter/ComprehensionAdapter.java 2008-12-12 03:57:33 UTC (rev 5739) @@ -1,14 +1,12 @@ package org.python.antlr.adapter; -import org.python.core.Py; -import org.python.core.PyObject; -import org.python.core.PyJavaInstance; - -import org.python.antlr.ast.comprehension; - import java.util.ArrayList; import java.util.List; +import org.python.antlr.ast.comprehension; +import org.python.core.Py; +import org.python.core.PyObject; + public class ComprehensionAdapter implements AstAdapter { public Object py2ast(PyObject o) { Modified: trunk/jython/src/org/python/antlr/adapter/ExcepthandlerAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/ExcepthandlerAdapter.java 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/src/org/python/antlr/adapter/ExcepthandlerAdapter.java 2008-12-12 03:57:33 UTC (rev 5739) @@ -1,15 +1,12 @@ package org.python.antlr.adapter; -import org.python.core.Py; -import org.python.core.PyObject; -import org.python.core.PyJavaInstance; - -import org.python.antlr.ast.ExceptHandler; -import org.python.antlr.ast.Num; - import java.util.ArrayList; import java.util.List; +import org.python.antlr.ast.ExceptHandler; +import org.python.core.Py; +import org.python.core.PyObject; + public class ExcepthandlerAdapter implements AstAdapter { public Object py2ast(PyObject o) { Modified: trunk/jython/src/org/python/antlr/adapter/ExprAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/ExprAdapter.java 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/src/org/python/antlr/adapter/ExprAdapter.java 2008-12-12 03:57:33 UTC (rev 5739) @@ -1,24 +1,22 @@ package org.python.antlr.adapter; +import java.util.ArrayList; +import java.util.List; + +import org.python.antlr.ast.Num; +import org.python.antlr.ast.Str; +import org.python.antlr.base.expr; import org.python.core.Py; import org.python.core.PyComplex; import org.python.core.PyFloat; import org.python.core.PyInteger; import org.python.core.PyLong; -import org.python.core.PyJavaInstance; import org.python.core.PyObject; import org.python.core.PyString; import org.python.core.PyUnicode; -import org.python.antlr.base.expr; -import org.python.antlr.ast.Num; -import org.python.antlr.ast.Str; - -import java.util.ArrayList; -import java.util.List; - public class ExprAdapter implements AstAdapter { - + public Object py2ast(PyObject o) { if (o == null || o instanceof expr) { return o; Modified: trunk/jython/src/org/python/antlr/adapter/IdentifierAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/IdentifierAdapter.java 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/src/org/python/antlr/adapter/IdentifierAdapter.java 2008-12-12 03:57:33 UTC (rev 5739) @@ -1,15 +1,11 @@ package org.python.antlr.adapter; -import org.python.core.Py; -import org.python.core.PyJavaInstance; -import org.python.core.PyObject; -import org.python.core.PyString; - -import org.python.antlr.ast.Num; - import java.util.ArrayList; import java.util.List; +import org.python.core.PyObject; +import org.python.core.PyString; + public class IdentifierAdapter implements AstAdapter { public Object py2ast(PyObject o) { Modified: trunk/jython/src/org/python/antlr/adapter/KeywordAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/KeywordAdapter.java 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/src/org/python/antlr/adapter/KeywordAdapter.java 2008-12-12 03:57:33 UTC (rev 5739) @@ -1,14 +1,12 @@ package org.python.antlr.adapter; -import org.python.core.Py; -import org.python.core.PyJavaInstance; -import org.python.core.PyObject; - -import org.python.antlr.ast.keyword; - import java.util.ArrayList; import java.util.List; +import org.python.antlr.ast.keyword; +import org.python.core.Py; +import org.python.core.PyObject; + public class KeywordAdapter implements AstAdapter { public Object py2ast(PyObject o) { Modified: trunk/jython/src/org/python/antlr/adapter/SliceAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/SliceAdapter.java 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/src/org/python/antlr/adapter/SliceAdapter.java 2008-12-12 03:57:33 UTC (rev 5739) @@ -1,15 +1,12 @@ package org.python.antlr.adapter; -import org.python.core.Py; -import org.python.core.PyJavaInstance; -import org.python.core.PyObject; - -import org.python.antlr.ast.Num; -import org.python.antlr.base.slice; - import java.util.ArrayList; import java.util.List; +import org.python.antlr.base.slice; +import org.python.core.Py; +import org.python.core.PyObject; + public class SliceAdapter implements AstAdapter { public Object py2ast(PyObject o) { Modified: trunk/jython/src/org/python/antlr/adapter/StmtAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/StmtAdapter.java 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/src/org/python/antlr/adapter/StmtAdapter.java 2008-12-12 03:57:33 UTC (rev 5739) @@ -1,14 +1,12 @@ package org.python.antlr.adapter; -import org.python.core.Py; -import org.python.core.PyJavaInstance; -import org.python.core.PyObject; - -import org.python.antlr.base.stmt; - import java.util.ArrayList; import java.util.List; +import org.python.antlr.base.stmt; +import org.python.core.Py; +import org.python.core.PyObject; + public class StmtAdapter implements AstAdapter { public Object py2ast(PyObject o) { Modified: trunk/jython/src/org/python/compiler/ProxyMaker.java =================================================================== --- trunk/jython/src/org/python/compiler/ProxyMaker.java 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/src/org/python/compiler/ProxyMaker.java 2008-12-12 03:57:33 UTC (rev 5739) @@ -12,6 +12,9 @@ import java.util.Set; import org.python.core.Py; +import org.python.core.PyJavaType; +import org.python.core.PyObject; +import org.python.core.PyProxy; import org.python.objectweb.asm.Label; import org.python.objectweb.asm.Opcodes; import org.python.util.Generic; @@ -53,13 +56,40 @@ else return ((Integer)i).intValue(); } + /** + * Retrieves <code>name</code> from the PyObject in <code>proxy</code> if it's defined in + * Python. This is a specialized helper function for internal PyProxy use. + */ + public static PyObject findPython(PyProxy proxy, String name) { + PyObject o = proxy._getPyInstance(); + if (o == null) { + proxy.__initProxy__(new Object[0]); + o = proxy._getPyInstance(); + } + PyObject ret = null; + if (o.getDict() != null) { + ret = o.getDict().__finditem__(name); + } + if (ret == null) { + PyObject[] definedOn = new PyObject[1]; + PyObject typeDefined = o.getType().lookup_where(name, definedOn); + if (!(definedOn[0] instanceof PyJavaType)) { + ret = typeDefined; + } + } + if (ret == null) { + return null; + } + Py.setSystemState(proxy._getPySystemState()); + return ret.__get__(o, null); + } + Class<?> superclass; Class<?>[] interfaces; Set<String> names; Set<String> supernames = Generic.set(); public ClassFile classfile; public String myClass; - public boolean isAdapter=false; public ProxyMaker(String classname, Class<?> superclass) { this.myClass = "org.python.proxies."+classname; @@ -432,7 +462,8 @@ if (!isAbstract) { int tmp = code.getLocal("org/python/core/PyObject"); - code.invokestatic("org/python/core/Py", "jfindattr", "(" + $pyProxy + $str + ")" + $pyObj); + code.invokestatic("org/python/compiler/ProxyMaker", "findPython", "(" + $pyProxy + $str + + ")" + $pyObj); code.astore(tmp); code.aload(tmp); @@ -449,20 +480,15 @@ addSuperMethod("super__"+name, name, superClass, parameters, ret, sig, access); } else { - if (!isAdapter) { - code.invokestatic("org/python/core/Py", "jgetattr", "(" + $pyProxy + $str + ")" + $pyObj); - callMethod(code, name, parameters, ret, method.getExceptionTypes()); - } else { - code.invokestatic("org/python/core/Py", "jfindattr", "(" + $pyProxy + $str + ")" + $pyObj); - code.dup(); - Label returnNull = new Label(); - code.ifnull(returnNull); - - callMethod(code, name, parameters, ret, method.getExceptionTypes()); - code.label(returnNull); - code.pop(); - doNullReturn(code, ret); - } + code.invokestatic("org/python/compiler/ProxyMaker", "findPython", "(" + $pyProxy + $str + + ")" + $pyObj); + code.dup(); + Label returnNull = new Label(); + code.ifnull(returnNull); + callMethod(code, name, parameters, ret, method.getExceptionTypes()); + code.label(returnNull); + code.pop(); + doNullReturn(code, ret); } } @@ -600,23 +626,23 @@ public void addProxy() throws Exception { // implement PyProxy interface - classfile.addField("__proxy", "Lorg/python/core/PyInstance;", + classfile.addField("__proxy", "Lorg/python/core/PyObject;", Modifier.PROTECTED); // setProxy methods Code code = classfile.addMethod("_setPyInstance", - "(Lorg/python/core/PyInstance;)V", + "(Lorg/python/core/PyObject;)V", Modifier.PUBLIC); code.aload(0); code.aload(1); - code.putfield(classfile.name, "__proxy", "Lorg/python/core/PyInstance;"); + code.putfield(classfile.name, "__proxy", "Lorg/python/core/PyObject;"); code.return_(); // getProxy method code = classfile.addMethod("_getPyInstance", - "()Lorg/python/core/PyInstance;", + "()Lorg/python/core/PyObject;", Modifier.PUBLIC); code.aload(0); - code.getfield(classfile.name, "__proxy", "Lorg/python/core/PyInstance;"); + code.getfield(classfile.name, "__proxy", "Lorg/python/core/PyObject;"); code.areturn(); // implement PyProxy interface Modified: trunk/jython/src/org/python/core/AstList.java =================================================================== --- trunk/jython/src/org/python/core/AstList.java 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/src/org/python/core/AstList.java 2008-12-12 03:57:33 UTC (rev 5739) @@ -6,13 +6,6 @@ */ package org.python.core; -import org.python.antlr.adapter.AstAdapter; -import org.python.expose.ExposedGet; -import org.python.expose.ExposedMethod; -import org.python.expose.ExposedNew; -import org.python.expose.ExposedType; -import org.python.expose.MethodType; - import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -20,6 +13,12 @@ import java.util.List; import java.util.ListIterator; +import org.python.antlr.adapter.AstAdapter; +import org.python.expose.ExposedGet; +import org.python.expose.ExposedMethod; +import org.python.expose.ExposedType; +import org.python.expose.MethodType; + @ExposedType(name = "_ast.astlist", base = PyList.class) public class AstList extends PySequence implements Cloneable, List { @@ -269,7 +268,7 @@ final String astlist_toString() { return data.toString(); } - + public void append(PyObject o) { astlist_append(o); } @@ -331,8 +330,8 @@ private int _index(PyObject o, String message, int start, int stop) { // Follow Python 2.3+ behavior - int validStop = calculateIndex(stop); - int validStart = calculateIndex(start); + int validStop = boundToSequence(stop); + int validStart = boundToSequence(start); for(int i = validStart; i < validStop && i < size(); i++) { if(data.get(i).equals(o)) { return i; @@ -358,7 +357,7 @@ } } } - + @ExposedMethod final void astlist_extend(PyObject iterable){ int length = size(); @@ -401,7 +400,7 @@ } data.add(index, o); } - + @ExposedMethod final void astlist_remove(PyObject value){ del(_index(value, "astlist.remove(x): x not in list", 0, size())); @@ -434,7 +433,7 @@ return (PyObject)data.remove(n); } Object element = data.remove(n); - return (PyObject)adapter.ast2py(element); + return adapter.ast2py(element); } @@ -454,7 +453,7 @@ } return new AstList(newList); } - + protected void set(int i, PyObject value) { data.set(i, value); } Deleted: trunk/jython/src/org/python/core/AutoInternalTables.java =================================================================== --- trunk/jython/src/org/python/core/AutoInternalTables.java 2008-12-12 03:31:52 UTC (rev 5738) +++ trunk/jython/src/org/python/core/AutoInternalTables.java 2008-12-12 03:57:33 UTC (rev 5739) @@ -1,155 +0,0 @@ -// Copyright 2000 Samuele Pedroni - -package org.python.core; - -import java.lang.ref.Reference; -import java.lang.ref.ReferenceQueue; -import java.util.Map; - -public abstract class AutoInternalTables extends InternalTables { - - protected transient ReferenceQueue queue = new ReferenceQueue(); - - protected abstract Reference newAutoRef(short type, Object key, - Object obj); - protected abstract short getAutoRefType(Reference ref); - protected abstract Object getAutoRefKey(Reference ref); - - private synchronized void cleanup() { - if (this.keepstable >= this.GSTABLE) - return; - this.adapters.remove(null); // trick - Reference ref; - while ((ref = this.queue.poll()) != null) { - Object key = getAutoRefKey(ref); - switch(getAutoRefType(ref)) { - case JCLASS: - Class cl = (Class)key; - this.classes.remove(cl); - classesDec(cl.getName()); - break; - case LAZY_JCLASS: - this.lazyClasses.remove(key); - break; - case ADAPTER_CLASS: - this.adapterClasses.remove(key); - } - } - } - - - protected boolean queryCanonical(String name) { - cleanup(); - return super.queryCanonical(name); - } - - protected PyJavaClass getCanonical(Class c) { - cleanup(); - Reference ref = (Reference)classesGet(c); - if (ref == null) return null; - return (PyJavaClass)ref.get(); - } - - protected PyJavaClass getLazyCanonical(String name) { - cleanup(); - Reference ref = (Reference)this.lazyClasses.get(name); - if (ref == null) return null; - return (PyJavaClass)ref.get(); - } - - protected void putCanonical(Class c,PyJavaClass canonical) { - cleanup(); - classesPut(c,newAutoRef(JCLASS,c,canonical)); - } - - protected void putLazyCanonical(String name,PyJavaClass canonical) { - cleanup(); - this.lazyClasses.put(name,newAutoRef(LAZY_JCLASS,name,canonical)); - } - - protected Class getAdapterClass(Class c) { - cleanup(); - Reference ref = (Reference)this.adapterClasses.get(c); - if (ref == null) return null; - return (Class)ref.get(); - } - - protected void putAdapterClass(Class c,Class ac) { - cleanup(); - this.adapterClasses.put(c,newAutoRef(ADAPTER_CLASS,c,ac)); - } - - protected Object getAdapter(Object o,String evc) { - cleanup(); - return super.getAdapter(o,evc); - } - - protected void putAdapter(Object o,String evc,Object ad) { - cleanup(); - super.putAdapter(o,evc,ad); - } - - - public boolean _doesSomeAutoUnload() { return ... [truncated message content] |
From: <cg...@us...> - 2008-12-12 03:31:58
|
Revision: 5738 http://jython.svn.sourceforge.net/jython/?rev=5738&view=rev Author: cgroves Date: 2008-12-12 03:31:52 +0000 (Fri, 12 Dec 2008) Log Message: ----------- Initialized merge tracking via "svnmerge" with revisions "1-5563" from https://jython.svn.sourceforge.net/svnroot/jython/branches/newstyle-java-types Property Changed: ---------------- trunk/jython/ Property changes on: trunk/jython ___________________________________________________________________ Modified: svnmerge-integrated - /branches/astwrite:1-5692 + /branches/astwrite:1-5692 /branches/newstyle-java-types:1-5563 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-12 03:29:55
|
Revision: 5737 http://jython.svn.sourceforge.net/jython/?rev=5737&view=rev Author: cgroves Date: 2008-12-12 03:29:49 +0000 (Fri, 12 Dec 2008) Log Message: ----------- Merged revisions 5730-5731,5733-5735 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython ........ r5730 | pjenvey | 2008-12-09 23:34:57 -0800 (Tue, 09 Dec 2008) | 1 line hide posixy stuff when not on posix ........ r5731 | pjenvey | 2008-12-10 00:10:31 -0800 (Wed, 10 Dec 2008) | 3 lines merge in new test from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_with.py -c 67684 ........ r5733 | pjenvey | 2008-12-10 16:10:25 -0800 (Wed, 10 Dec 2008) | 4 lines fail fast when path exists but isn't a normal file suggested by Ethan Glasser-Camp fixes #1199 ........ r5734 | pjenvey | 2008-12-10 16:39:49 -0800 (Wed, 10 Dec 2008) | 1 line COMPUTE_FRAMES implies COMPUTE_MAXS ........ r5735 | pjenvey | 2008-12-10 21:20:55 -0800 (Wed, 10 Dec 2008) | 6 lines o fix imp.find_module not finding builtin modules o add __builtin__ and sys to sys.builtin_module_names and another hack for re-importing __builtin__ like we have for sys fixes #1161 thanks Sven Reimers ........ Modified Paths: -------------- branches/newstyle-java-types/Lib/os.py branches/newstyle-java-types/Lib/test/test_import_jy.py branches/newstyle-java-types/Lib/test/test_with.py branches/newstyle-java-types/src/org/python/compiler/ClassFile.java branches/newstyle-java-types/src/org/python/core/PySystemState.java branches/newstyle-java-types/src/org/python/core/imp.java branches/newstyle-java-types/src/org/python/modules/imp.java branches/newstyle-java-types/src/org/python/modules/zipimport/zipimporter.java Property Changed: ---------------- branches/newstyle-java-types/ Property changes on: branches/newstyle-java-types ___________________________________________________________________ Modified: svnmerge-integrated - /branches/nowalker:1-5263 /trunk/jython:1-5729 /branches/astwrite:1-5692 + /branches/astwrite:1-5692 /branches/nowalker:1-5263 /trunk/jython:1-5736 Modified: svn:mergeinfo - /trunk/jython:5565-5661,5670-5726 + /trunk/jython:5565-5661,5670-5726,5730-5735 Modified: branches/newstyle-java-types/Lib/os.py =================================================================== --- branches/newstyle-java-types/Lib/os.py 2008-12-11 09:15:43 UTC (rev 5736) +++ branches/newstyle-java-types/Lib/os.py 2008-12-12 03:29:49 UTC (rev 5737) @@ -494,6 +494,9 @@ except: raise f = File(sys.getPath(path)) + # XXX: jna-posix implements similar link detection in + # JavaFileStat.calculateSymlink, fallback to that instead when not + # native abs_parent = f.getAbsoluteFile().getParentFile() if not abs_parent: # root isn't a link @@ -669,29 +672,6 @@ except: raise OSError(errno.EBADF, strerror(errno.EBADF)) -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)) - - def symlink(src, dst): - """symlink(src, dst) - - Create a symbolic link pointing to src named dst. - """ - _posix.symlink(src, sys.getPath(dst)) - - def readlink(path): - """readlink(path) -> path - - Return a string representing the path to which the symbolic link - points. - """ - return _posix.readlink(sys.getPath(path)) - # Provide lazy popen*, and system objects # Do these lazily, as most jython programs don't need them, # and they are very expensive to initialize @@ -906,66 +886,89 @@ The optional second argument can specify an alternate default.""" return environ.get(key, default) -def getegid(): - """getegid() -> egid +if _name == 'posix': + def link(src, dst): + """link(src, dst) - Return the current process's effective group id.""" - return _posix.getegid() + Create a hard link to a file. + """ + _posix.link(sys.getPath(src), sys.getPath(dst)) -def geteuid(): - """geteuid() -> euid + def symlink(src, dst): + """symlink(src, dst) - Return the current process's effective user id.""" - return _posix.geteuid() + Create a symbolic link pointing to src named dst. + """ + _posix.symlink(src, sys.getPath(dst)) -def getgid(): - """getgid() -> gid + def readlink(path): + """readlink(path) -> path - Return the current process's group id.""" - return _posix.getgid() + Return a string representing the path to which the symbolic link + points. + """ + return _posix.readlink(sys.getPath(path)) -def getlogin(): - """getlogin() -> string + def getegid(): + """getegid() -> egid - Return the actual login name.""" - return _posix.getlogin() + Return the current process's effective group id.""" + return _posix.getegid() -def getpgrp(): - """getpgrp() -> pgrp + def geteuid(): + """geteuid() -> euid - Return the current process group id.""" - return _posix.getpgrp() + Return the current process's effective user id.""" + return _posix.geteuid() -def getpid(): - """getpid() -> pid + def getgid(): + """getgid() -> gid - Return the current process id.""" - return _posix.getpid() + Return the current process's group id.""" + return _posix.getgid() -def getppid(): - """getppid() -> ppid + def getlogin(): + """getlogin() -> string - Return the parent's process id.""" - return _posix.getppid() + Return the actual login name.""" + return _posix.getlogin() -def getuid(): - """getuid() -> uid + def getpgrp(): + """getpgrp() -> pgrp - Return the current process's user id.""" - return _posix.getuid() + Return the current process group id.""" + return _posix.getpgrp() -def setpgrp(): - """setpgrp() + def getppid(): + """getppid() -> ppid - Make this process a session leader.""" - return _posix.setpgrp() + Return the parent's process id.""" + return _posix.getppid() -def setsid(): - """setsid() + def getuid(): + """getuid() -> uid - Call the system call setsid().""" - return _posix.setsid() + Return the current process's user id.""" + return _posix.getuid() + def setpgrp(): + """setpgrp() + + Make this process a session leader.""" + return _posix.setpgrp() + + def setsid(): + """setsid() + + Call the system call setsid().""" + return _posix.setsid() + +def getpid(): + """getpid() -> pid + + Return the current process id.""" + return _posix.getpid() + def isatty(fileno): """isatty(fd) -> bool Modified: branches/newstyle-java-types/Lib/test/test_import_jy.py =================================================================== --- branches/newstyle-java-types/Lib/test/test_import_jy.py 2008-12-11 09:15:43 UTC (rev 5736) +++ branches/newstyle-java-types/Lib/test/test_import_jy.py 2008-12-12 03:29:49 UTC (rev 5737) @@ -90,6 +90,7 @@ self.assertEquals(bytecode, read(init_compiled), 'bytecode was recompiled') + class OverrideBuiltinsImportTestCase(unittest.TestCase): def test_override(self): tests = [ @@ -127,9 +128,19 @@ finally: __builtin__.__import__ = oldimp +class ImpTestCase(unittest.TestCase): + + def test_imp_find_module_builtins(self): + self.assertEqual(imp.find_module('sys'), (None, 'sys', ('', '', 6))) + self.assertEqual(imp.find_module('__builtin__'), + (None, '__builtin__', ('', '', 6))) + self.assertEqual(imp.find_module('imp'), (None, 'imp', ('', '', 6))) + + def test_main(): - test_classes = [MislabeledImportTestCase, OverrideBuiltinsImportTestCase] - test_support.run_unittest(*test_classes) + test_support.run_unittest(MislabeledImportTestCase, + OverrideBuiltinsImportTestCase, + ImpTestCase) if __name__ == '__main__': test_main() Modified: branches/newstyle-java-types/Lib/test/test_with.py =================================================================== --- branches/newstyle-java-types/Lib/test/test_with.py 2008-12-11 09:15:43 UTC (rev 5736) +++ branches/newstyle-java-types/Lib/test/test_with.py 2008-12-12 03:29:49 UTC (rev 5737) @@ -505,7 +505,37 @@ self.assertRaises(GeneratorExit, shouldThrow) + def testErrorsInBool(self): + # issue4589: __exit__ return code may raise an exception + # when looking at its truth value. + class cm(object): + def __init__(self, bool_conversion): + class Bool: + def __nonzero__(self): + return bool_conversion() + self.exit_result = Bool() + def __enter__(self): + return 3 + def __exit__(self, a, b, c): + return self.exit_result + + def trueAsBool(): + with cm(lambda: True): + self.fail("Should NOT see this") + trueAsBool() + + def falseAsBool(): + with cm(lambda: False): + self.fail("Should raise") + self.assertRaises(AssertionError, falseAsBool) + + def failAsBool(): + with cm(lambda: 1//0): + self.fail("Should NOT see this") + self.assertRaises(ZeroDivisionError, failAsBool) + + class NonLocalFlowControlTestCase(unittest.TestCase, ContextmanagerAssertionMixin): Modified: branches/newstyle-java-types/src/org/python/compiler/ClassFile.java =================================================================== --- branches/newstyle-java-types/src/org/python/compiler/ClassFile.java 2008-12-11 09:15:43 UTC (rev 5736) +++ branches/newstyle-java-types/src/org/python/compiler/ClassFile.java 2008-12-12 03:29:49 UTC (rev 5737) @@ -46,7 +46,7 @@ this.interfaces = new String[0]; this.access = access; - cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); + cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); methodVisitors = Collections.synchronizedList(new ArrayList()); fieldVisitors = Collections.synchronizedList(new ArrayList()); } Modified: branches/newstyle-java-types/src/org/python/core/PySystemState.java =================================================================== --- branches/newstyle-java-types/src/org/python/core/PySystemState.java 2008-12-11 09:15:43 UTC (rev 5736) +++ branches/newstyle-java-types/src/org/python/core/PySystemState.java 2008-12-12 03:29:49 UTC (rev 5737) @@ -709,6 +709,10 @@ private static void initBuiltins(Properties props) { builtinNames = new Hashtable(); + // add the oddball builtins that are specially handled + builtinNames.put("__builtin__", ""); + builtinNames.put("sys", ""); + // add builtins specified in the Setup.java file for (int i=0; i < Setup.builtinModules.length; i++) addBuiltin(Setup.builtinModules[i]); @@ -727,7 +731,7 @@ builtin_module_names = new PyTuple(built_mod); } - static String getBuiltin(String name) { + public static String getBuiltin(String name) { return (String)builtinNames.get(name); } Modified: branches/newstyle-java-types/src/org/python/core/imp.java =================================================================== --- branches/newstyle-java-types/src/org/python/core/imp.java 2008-12-11 09:15:43 UTC (rev 5736) +++ branches/newstyle-java-types/src/org/python/core/imp.java 2008-12-12 03:29:49 UTC (rev 5737) @@ -387,10 +387,13 @@ private static PyObject loadBuiltin(String name) { if (name == "sys") { - Py.writeComment(IMPORT_LOG, "'" + name + "' as sys in " - + "builtin modules"); + Py.writeComment(IMPORT_LOG, "'" + name + "' as sys in builtin modules"); return Py.java2py(Py.getSystemState()); } + if (name == "__builtin__") { + Py.writeComment(IMPORT_LOG, "'" + name + "' as __builtin__ in builtin modules"); + return new PyModule("__builtin__", PySystemState.builtins); + } String mod = PySystemState.getBuiltin(name); if (mod != null) { Class c = Py.findClassEx(mod, "builtin modules"); Modified: branches/newstyle-java-types/src/org/python/modules/imp.java =================================================================== --- branches/newstyle-java-types/src/org/python/modules/imp.java 2008-12-11 09:15:43 UTC (rev 5736) +++ branches/newstyle-java-types/src/org/python/modules/imp.java 2008-12-12 03:29:49 UTC (rev 5737) @@ -129,10 +129,6 @@ return null; } - public static PyObject find_module(String name) { - return find_module(name, null); - } - public static PyObject load_source(String modname, String filename) { return load_source(modname, filename, null); } @@ -158,11 +154,20 @@ return mod; } + public static PyObject find_module(String name) { + return find_module(name, Py.None); + } + public static PyObject find_module(String name, PyObject path) { - if (path == null || path == Py.None) { + if (path == Py.None && PySystemState.getBuiltin(name) != null) { + return new PyTuple(Py.None, Py.newString(name), + new PyTuple(Py.EmptyString, Py.EmptyString, + Py.newInteger(C_BUILTIN))); + } + + if (path == Py.None) { path = Py.getSystemState().path; } - for (PyObject p : path.asIterable()) { ModuleInfo mi = findFromSource(name, p.toString(), false, true); if(mi == null) { Modified: branches/newstyle-java-types/src/org/python/modules/zipimport/zipimporter.java =================================================================== --- branches/newstyle-java-types/src/org/python/modules/zipimport/zipimporter.java 2008-12-11 09:15:43 UTC (rev 5736) +++ branches/newstyle-java-types/src/org/python/modules/zipimport/zipimporter.java 2008-12-12 03:29:49 UTC (rev 5737) @@ -115,8 +115,10 @@ prefix = ""; while (true) { File fullPathFile = new File(sys.getPath(pathFile.getPath())); - if (fullPathFile.isFile()) { - archive = pathFile.getPath(); + if (fullPathFile.exists()) { + if (fullPathFile.isFile()) { + archive = pathFile.getPath(); + } break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2008-12-11 09:15:47
|
Revision: 5736 http://jython.svn.sourceforge.net/jython/?rev=5736&view=rev Author: otmarhumbel Date: 2008-12-11 09:15:43 +0000 (Thu, 11 Dec 2008) Log Message: ----------- - unified handling of java home - provide a fallback mechanism for an invalid java.home system property Modified Paths: -------------- trunk/installer/src/java/org/python/util/install/ConsoleInstaller.java trunk/installer/src/java/org/python/util/install/DirectorySelectionPage.java trunk/installer/src/java/org/python/util/install/FrameInstaller.java trunk/installer/src/java/org/python/util/install/Installation.java trunk/installer/src/java/org/python/util/install/InstallerCommandLine.java trunk/installer/src/java/org/python/util/install/JarInstaller.java trunk/installer/src/java/org/python/util/install/JavaSelectionPage.java trunk/installer/src/java/org/python/util/install/JavaSelectionPageValidator.java trunk/installer/src/java/org/python/util/install/JavaVersionTester.java trunk/installer/src/java/org/python/util/install/ProgressPage.java trunk/installer/src/java/org/python/util/install/StartScriptGenerator.java trunk/installer/src/java/org/python/util/install/driver/Autotest.java trunk/installer/src/java/org/python/util/install/driver/InstallationDriver.java trunk/installer/src/java/org/python/util/install/driver/NormalVerifier.java trunk/installer/src/java/org/python/util/install/driver/StandaloneVerifier.java trunk/installer/test/java/org/python/util/install/FrameInstallerTest.java trunk/installer/test/java/org/python/util/install/InstallationTest.java trunk/installer/test/java/org/python/util/install/InstallerCommandLineTest.java trunk/installer/test/java/org/python/util/install/JavaTest_Standalone.java trunk/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java trunk/installer/test/java/org/python/util/install/driver/NormalVerifierTest.java Added Paths: ----------- trunk/installer/src/java/org/python/util/install/JavaHomeHandler.java trunk/installer/test/java/org/python/util/install/JavaHomeHandlerTest.java Modified: trunk/installer/src/java/org/python/util/install/ConsoleInstaller.java =================================================================== --- trunk/installer/src/java/org/python/util/install/ConsoleInstaller.java 2008-12-11 05:20:55 UTC (rev 5735) +++ trunk/installer/src/java/org/python/util/install/ConsoleInstaller.java 2008-12-11 09:15:43 UTC (rev 5736) @@ -10,20 +10,27 @@ import java.util.List; import java.util.Locale; -import org.python.util.install.Installation.JavaFilenameFilter; import org.python.util.install.Installation.JavaVersionInfo; import org.python.util.install.driver.Tunnel; public class ConsoleInstaller implements ProgressListener, TextKeys { + private static final String _CANCEL = "c"; + private static final String _PROMPT = ">>>"; + private static final String _BEGIN_ANSWERS = "["; + private static final String _END_ANSWERS = "]"; + private static final String _CURRENT = "=="; private InstallerCommandLine _commandLine; + private JarInstaller _jarInstaller; + private JarInfo _jarInfo; + private Tunnel _tunnel; public ConsoleInstaller(InstallerCommandLine commandLine, JarInfo jarInfo) { @@ -38,24 +45,26 @@ public void install() { File targetDirectory = null; - File javaHome = null; + JavaHomeHandler javaHomeHandler = null; if (_commandLine.hasConsoleOption()) { welcome(); selectLanguage(); acceptLicense(); InstallationType installationType = selectInstallationType(); targetDirectory = determineTargetDirectory(); - javaHome = checkVersion(determineJavaHome()); - promptForCopying(targetDirectory, installationType, javaHome); - _jarInstaller.inflate(targetDirectory, installationType, javaHome); + javaHomeHandler = checkVersion(determineJavaHome()); + promptForCopying(targetDirectory, installationType, javaHomeHandler); + _jarInstaller.inflate(targetDirectory, installationType, javaHomeHandler); showReadme(targetDirectory); success(targetDirectory); } else if (_commandLine.hasSilentOption()) { message(getText(C_SILENT_INSTALLATION)); targetDirectory = _commandLine.getTargetDirectory(); checkTargetDirectorySilent(targetDirectory); - javaHome = checkVersionSilent(_commandLine.getJavaHome()); - _jarInstaller.inflate(targetDirectory, _commandLine.getInstallationType(), javaHome); + javaHomeHandler = checkVersionSilent(_commandLine.getJavaHomeHandler()); + _jarInstaller.inflate(targetDirectory, + _commandLine.getInstallationType(), + javaHomeHandler); success(targetDirectory); } } @@ -85,7 +94,8 @@ /** * question and answer * - * @param answers Possible answers (may be null) + * @param answers + * Possible answers (may be null) * @return (chosen) answer */ private String question(String question, List<String> answers, boolean answerRequired) { @@ -170,7 +180,7 @@ languages = languages.substring(0, languages.length() - 2); message(getText(C_AVAILABLE_LANGUAGES, languages)); String answer = question(getText(C_SELECT_LANGUAGE), answers); - if (answer.equalsIgnoreCase((String) answers.get(1))) { + if (answer.equalsIgnoreCase((String)answers.get(1))) { Installation.setLanguage(Locale.GERMAN); } else { Installation.setLanguage(Locale.ENGLISH); @@ -243,11 +253,12 @@ return installationType; } - private File checkVersion(File javaHome) { + private JavaHomeHandler checkVersion(JavaHomeHandler javaHomeHandler) { // handle target java version - JavaInfo javaInfo = verifyTargetJava(javaHome); - message(getText(C_JAVA_VERSION, javaInfo.getJavaVersionInfo().getVendor(), javaInfo.getJavaVersionInfo() - .getVersion())); + JavaInfo javaInfo = verifyTargetJava(javaHomeHandler); + message(getText(C_JAVA_VERSION, + javaInfo.getJavaVersionInfo().getVendor(), + javaInfo.getJavaVersionInfo().getVersion())); if (Installation.isValidJava(javaInfo.getJavaVersionInfo())) { question(getText(C_PROCEED)); } else { @@ -264,12 +275,12 @@ message(getText(C_UNSUPPORTED_OS)); question(getText(C_PROCEED_ANYWAY)); } - return javaInfo.getJavaHome(); + return javaInfo.getJavaHomeHandler(); } - private File checkVersionSilent(File javaHome) { + private JavaHomeHandler checkVersionSilent(JavaHomeHandler javaHomeHandler) { // check target java version - JavaInfo javaInfo = verifyTargetJava(javaHome); + JavaInfo javaInfo = verifyTargetJava(javaHomeHandler); if (!Installation.isValidJava(javaInfo.getJavaVersionInfo())) { message(getText(C_UNSUPPORTED_JAVA)); } @@ -277,31 +288,22 @@ if (!Installation.isValidOs()) { message(getText(C_UNSUPPORTED_OS)); } - return javaInfo.getJavaHome(); + return javaInfo.getJavaHomeHandler(); } - private JavaInfo verifyTargetJava(File javaHome) { + private JavaInfo verifyTargetJava(JavaHomeHandler javaHomeHandler) { JavaVersionInfo javaVersionInfo = new JavaVersionInfo(); - String currentJavaHomeName = System.getProperty(JavaVersionTester.JAVA_HOME); - if (javaHome != null) { - if (currentJavaHomeName.equals(javaHome.getAbsolutePath())) { - // no experiments if current java is selected - javaHome = null; - } else { - javaVersionInfo = Installation.getExternalJavaVersion(javaHome); - if (javaVersionInfo.getErrorCode() != Installation.NORMAL_RETURN) { - // switch back to current if an error occurred - message(getText(C_TO_CURRENT_JAVA, javaVersionInfo.getReason())); - javaHome = null; - } + Installation.fillJavaVersionInfo(javaVersionInfo, System.getProperties()); // a priori + if (javaHomeHandler.isDeviation()) { + javaVersionInfo = Installation.getExternalJavaVersion(javaHomeHandler); + if (javaVersionInfo.getErrorCode() != Installation.NORMAL_RETURN) { + // switch back to current if an error occurred + message(getText(C_TO_CURRENT_JAVA, javaVersionInfo.getReason())); + javaHomeHandler = new JavaHomeHandler(); } } - if (javaHome == null) { - Installation.fillJavaVersionInfo(javaVersionInfo, System.getProperties()); - javaHome = new File(currentJavaHomeName); - } JavaInfo javaInfo = new JavaInfo(); - javaInfo.setJavaHome(javaHome); + javaInfo.setJavaHomeHandler(javaHomeHandler); javaInfo.setJavaVersionInfo(javaVersionInfo); return javaInfo; } @@ -333,11 +335,13 @@ message(getText(C_NOT_A_DIRECTORY, targetDirectory.getCanonicalPath())); } else { if (targetDirectory.list().length > 0) { - String overwrite = question(getText(C_OVERWRITE_DIRECTORY, targetDirectory - .getCanonicalPath()), getYNAnswers()); + String overwrite = question(getText(C_OVERWRITE_DIRECTORY, + targetDirectory.getCanonicalPath()), + getYNAnswers()); if (overwrite.equalsIgnoreCase(getText(C_YES))) { - String clear = question(getText(C_CLEAR_DIRECTORY, targetDirectory.getCanonicalPath()), - getYNAnswers()); + String clear = question(getText(C_CLEAR_DIRECTORY, + targetDirectory.getCanonicalPath()), + getYNAnswers()); if (clear.equalsIgnoreCase(getText(C_YES))) { clearDirectory(targetDirectory); } @@ -345,57 +349,48 @@ } } } else { - String create = question(getText(C_CREATE_DIRECTORY, targetDirectory.getCanonicalPath()), - getYNAnswers()); + String create = question(getText(C_CREATE_DIRECTORY, + targetDirectory.getCanonicalPath()), + getYNAnswers()); if (create.equalsIgnoreCase(getText(C_YES))) { if (!targetDirectory.mkdirs()) { - throw new InstallerException(getText(C_UNABLE_CREATE_DIRECTORY, targetDirectory - .getCanonicalPath())); + throw new InstallerException(getText(C_UNABLE_CREATE_DIRECTORY, + targetDirectory.getCanonicalPath())); } } } - } while (!targetDirectory.exists() || !targetDirectory.isDirectory() || targetDirectory.list().length > 0); + } while (!targetDirectory.exists() || !targetDirectory.isDirectory() + || targetDirectory.list().length > 0); } catch (IOException ioe) { throw new InstallerException(ioe); } return targetDirectory; } - private File determineJavaHome() { - File javaHome = null; - File binDir = null; - try { - boolean javaFound = false; - do { - String javaHomeName = question(getText(C_ENTER_JAVA_HOME, _CURRENT), true); - if (_CURRENT.equals(javaHomeName)) { - javaHome = new File(System.getProperty(JavaVersionTester.JAVA_HOME)); - } else { - javaHome = new File(javaHomeName); - } - if (!javaHome.exists()) { - message(getText(C_NOT_FOUND, javaHome.getCanonicalPath())); - } else { - if (!javaHome.isDirectory()) { - message(getText(C_NOT_A_DIRECTORY, javaHome.getCanonicalPath())); + private JavaHomeHandler determineJavaHome() { + JavaHomeHandler javaHomeHandler = null; + boolean javaFound = false; + while (!javaFound) { + String javaHomeName = question(getText(C_ENTER_JAVA_HOME, _CURRENT), true); + // only validate deviations + if (_CURRENT.equals(javaHomeName)) { + javaHomeHandler = new JavaHomeHandler(); + javaFound = true; + } else { + javaHomeHandler = new JavaHomeHandler(javaHomeName); + if (javaHomeHandler.isDeviation()) { + if (!javaHomeHandler.isValidHome()) { + String binDirName = javaHomeName.concat("/bin"); + message(getText(C_NO_JAVA_EXECUTABLE, binDirName)); } else { - binDir = new File(javaHome, "bin"); - if (!binDir.exists()) { - message(getText(C_NO_BIN_DIRECTORY, javaHome.getCanonicalPath())); - } else { - if (binDir.list(new JavaFilenameFilter()).length <= 0) { - message(getText(C_NO_JAVA_EXECUTABLE, binDir.getCanonicalPath())); - } else { - javaFound = true; - } - } + javaFound = true; } + } else { + javaFound = true; } - } while (!javaHome.exists() || !javaHome.isDirectory() || !binDir.exists() || !javaFound); - } catch (IOException ioe) { - throw new InstallerException(ioe); + } } - return javaHome; + return javaHomeHandler; } private void checkTargetDirectorySilent(File targetDirectory) { @@ -403,16 +398,18 @@ if (!targetDirectory.exists()) { // create directory if (!targetDirectory.mkdirs()) { - throw new InstallerException(getText(C_UNABLE_CREATE_DIRECTORY, targetDirectory.getCanonicalPath())); + throw new InstallerException(getText(C_UNABLE_CREATE_DIRECTORY, + targetDirectory.getCanonicalPath())); } } else { // assert it is an empty directory if (!targetDirectory.isDirectory()) { - throw new InstallerException(getText(C_NOT_A_DIRECTORY, targetDirectory.getCanonicalPath())); + throw new InstallerException(getText(C_NOT_A_DIRECTORY, + targetDirectory.getCanonicalPath())); } else { if (targetDirectory.list().length > 0) { - throw new InstallerException(getText(C_NON_EMPTY_TARGET_DIRECTORY, targetDirectory - .getCanonicalPath())); + throw new InstallerException(getText(C_NON_EMPTY_TARGET_DIRECTORY, + targetDirectory.getCanonicalPath())); } } } @@ -445,8 +442,9 @@ } } - private void promptForCopying(final File targetDirectory, final InstallationType installationType, - final File javaHome) { + private void promptForCopying(final File targetDirectory, + final InstallationType installationType, + final JavaHomeHandler javaHomeHandler) { try { message(getText(C_SUMMARY)); if (installationType.isStandalone()) { @@ -458,10 +456,16 @@ + installationType.installDemosAndExamples()); message(" - " + InstallerCommandLine.INEXCLUDE_DOCUMENTATION + ": " + installationType.installDocumentation()); - message(" - " + InstallerCommandLine.INEXCLUDE_SOURCES + ": " + installationType.installSources()); - message(" - JRE: " + javaHome.getAbsolutePath()); + message(" - " + InstallerCommandLine.INEXCLUDE_SOURCES + ": " + + installationType.installSources()); + if (javaHomeHandler.isValidHome()) { + message(" - JRE: " + javaHomeHandler.getHome().getAbsolutePath()); + } else { + message(" - java"); + } } - String proceed = question(getText(C_CONFIRM_TARGET, targetDirectory.getCanonicalPath()), getYNAnswers()); + String proceed = question(getText(C_CONFIRM_TARGET, targetDirectory.getCanonicalPath()), + getYNAnswers()); if (!proceed.equalsIgnoreCase(getText(C_YES))) { throw new InstallationCancelledException(); } @@ -479,14 +483,14 @@ } } - private List<String> getTypeAnswers() { - List<String> answers = new ArrayList<String>(4); + private List<String> getTypeAnswers() { + List<String> answers = new ArrayList<String>(4); answers.add(Installation.ALL); answers.add(Installation.STANDARD); answers.add(Installation.MINIMUM); answers.add(Installation.STANDALONE); - return answers; - } + return answers; + } private List<String> getYNAnswers() { List<String> answers = new ArrayList<String>(2); @@ -502,9 +506,9 @@ answers.add(InstallerCommandLine.INEXCLUDE_DOCUMENTATION); answers.add(InstallerCommandLine.INEXCLUDE_SOURCES); answers.add(getText(C_NO)); - return answers; + return answers; } - + private void progressMessage(int percentage) { message(" " + percentage + " %"); } @@ -522,15 +526,17 @@ } private static class JavaInfo { + private JavaVersionInfo _javaVersionInfo; - private File _javaHome; - void setJavaHome(File javaHome) { - _javaHome = javaHome; + private JavaHomeHandler _javaHomeHandler; + + void setJavaHomeHandler(JavaHomeHandler javaHomeHandler) { + _javaHomeHandler = javaHomeHandler; } - File getJavaHome() { - return _javaHome; + JavaHomeHandler getJavaHomeHandler() { + return _javaHomeHandler; } void setJavaVersionInfo(JavaVersionInfo javaVersionInfo) { @@ -545,7 +551,6 @@ // // interface ProgressListener // - public void progressChanged(int newPercentage) { progressMessage(newPercentage); } @@ -559,7 +564,7 @@ } public void progressEntry(String entry) { - // ignore the single entries - only used in gui mode + // ignore the single entries - only used in gui mode } public void progressStartScripts() { @@ -569,5 +574,4 @@ public void progressStandalone() { message(getText(C_PACKING_STANDALONE_JAR)); } - } \ No newline at end of file Modified: trunk/installer/src/java/org/python/util/install/DirectorySelectionPage.java =================================================================== --- trunk/installer/src/java/org/python/util/install/DirectorySelectionPage.java 2008-12-11 05:20:55 UTC (rev 5735) +++ trunk/installer/src/java/org/python/util/install/DirectorySelectionPage.java 2008-12-11 09:15:43 UTC (rev 5736) @@ -17,6 +17,9 @@ import javax.swing.JTextField; public class DirectorySelectionPage extends AbstractWizardPage { + + private static final long serialVersionUID = -3672273150338356549L; + private JLabel _label; private JTextField _directory; private JButton _browse; @@ -111,9 +114,14 @@ File defaultDirectory = null; // 1st try (on windows): root if (Installation.isWindows()) { - directory = System.getProperty(JavaVersionTester.JAVA_HOME, "C:"); - if (directory.length() > 2) { - directory = directory.substring(0, 2); + JavaHomeHandler handler = new JavaHomeHandler(); + if (handler.isValidHome()) { + directory = handler.getHome().getAbsolutePath(); + if (directory.length() > 2) { + directory = directory.substring(0, 2); + } + } else { + directory = "C:"; } defaultDirectory = makeJythonSubDirectory(directory); } Modified: trunk/installer/src/java/org/python/util/install/FrameInstaller.java =================================================================== --- trunk/installer/src/java/org/python/util/install/FrameInstaller.java 2008-12-11 05:20:55 UTC (rev 5735) +++ trunk/installer/src/java/org/python/util/install/FrameInstaller.java 2008-12-11 09:15:43 UTC (rev 5736) @@ -26,6 +26,8 @@ private static Properties _properties = new Properties(); + private static JavaHomeHandler _javaHomeHandler; + protected FrameInstaller(InstallerCommandLine commandLine, JarInfo jarInfo, Autotest autotest) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); @@ -38,7 +40,7 @@ setTargetDirectory(commandLine.getTargetDirectory().getAbsolutePath()); } if (commandLine.hasJavaHomeOption()) { - setTargetJavaHome(commandLine.getJavaHome().getAbsolutePath()); + setJavaHomeHandler(commandLine.getJavaHomeHandler()); } Wizard wizard = new Wizard(jarInfo, autotest); wizard.addWindowListener(new WindowAdapter() { @@ -72,12 +74,15 @@ return getProperty(TextKeys.TARGET_DIRECTORY_PROPERTY); } - protected static void setTargetJavaHome(String javaHome) { - setProperty(TextKeys.TARGET_JAVA_HOME_PROPERTY, javaHome.trim()); + protected static void setJavaHomeHandler(JavaHomeHandler javaHomeHandler) { + _javaHomeHandler = javaHomeHandler; } - protected static String getTargetJavaHome() { - return getProperty(TextKeys.TARGET_JAVA_HOME_PROPERTY); + protected static JavaHomeHandler getJavaHomeHandler() { + if (_javaHomeHandler == null) { + _javaHomeHandler = new JavaHomeHandler(); + } + return _javaHomeHandler; } protected static void setLanguage(Locale locale) { Modified: trunk/installer/src/java/org/python/util/install/Installation.java =================================================================== --- trunk/installer/src/java/org/python/util/install/Installation.java 2008-12-11 05:20:55 UTC (rev 5735) +++ trunk/installer/src/java/org/python/util/install/Installation.java 2008-12-11 09:15:43 UTC (rev 5736) @@ -150,57 +150,53 @@ /** * Get the version info of an external (maybe other) jvm. * - * @param javaHome The java home of the external jvm. The /bin directory is assumed to be a direct child directory. + * @param javaHomeHandler + * The java home handler pointing to the java home of the external jvm.<br> + * The /bin directory is assumed to be a direct child directory. + * * @return The versionInfo */ - protected static JavaVersionInfo getExternalJavaVersion(File javaHome) { + protected static JavaVersionInfo getExternalJavaVersion(JavaHomeHandler javaHomeHandler) { JavaVersionInfo versionInfo = new JavaVersionInfo(); - - File binDirectory = new File(javaHome, "bin"); - if (binDirectory.exists() && binDirectory.isDirectory()) { - if (binDirectory.list(new JavaFilenameFilter()).length > 0) { - try { - ConsoleInstaller.message(getText(TextKeys.C_CHECK_JAVA_VERSION)); - // launch the java command - temporary file will be written by the child process - File tempFile = File.createTempFile("jython_installation", ".properties"); - if (tempFile.exists() && tempFile.canWrite()) { - String command[] = new String[5]; - command[0] = binDirectory.getAbsolutePath() + File.separator + "java"; - command[1] = "-cp"; - command[2] = System.getProperty("java.class.path"); // our own class path should be ok here - command[3] = JavaVersionTester.class.getName(); - command[4] = tempFile.getAbsolutePath(); - - if (isVerbose()) { - ConsoleInstaller.message("executing: " + command[0] + " " + command[1] + " " + command[2] - + " " + command[3] + " " + command[4]); - } - ChildProcess childProcess = new ChildProcess(command, 10000); // 10 seconds - childProcess.setDebug(Installation.isVerbose()); - int errorCode = childProcess.run(); - if (errorCode != NORMAL_RETURN) { - versionInfo.setErrorCode(errorCode); - versionInfo.setReason(getText(TextKeys.C_NO_VALID_JAVA, javaHome.getAbsolutePath())); - } else { - Properties tempProperties = new Properties(); - tempProperties.load(new FileInputStream(tempFile)); - fillJavaVersionInfo(versionInfo, tempProperties); - } + if (javaHomeHandler.isValidHome()) { + try { + ConsoleInstaller.message(getText(TextKeys.C_CHECK_JAVA_VERSION)); + // launch the java command - temporary file will be written by the child process + File tempFile = File.createTempFile("jython_installation", ".properties"); + if (tempFile.exists() && tempFile.canWrite()) { + String command[] = new String[5]; + command[0] = javaHomeHandler.getExecutableName(); + command[1] = "-cp"; + // our own class path should be ok here + command[2] = System.getProperty("java.class.path"); + command[3] = JavaVersionTester.class.getName(); + command[4] = tempFile.getAbsolutePath(); + if (isVerbose()) { + ConsoleInstaller.message("executing: " + command[0] + " " + command[1] + + " " + command[2] + " " + command[3] + " " + command[4]); + } + ChildProcess childProcess = new ChildProcess(command, 10000); // 10 seconds + childProcess.setDebug(Installation.isVerbose()); + int errorCode = childProcess.run(); + if (errorCode != NORMAL_RETURN) { + versionInfo.setErrorCode(errorCode); + versionInfo.setReason(getText(TextKeys.C_NO_VALID_JAVA, javaHomeHandler.toString())); } else { - versionInfo.setErrorCode(ERROR_RETURN); - versionInfo.setReason(getText(TextKeys.C_UNABLE_CREATE_TMPFILE, tempFile.getAbsolutePath())); + Properties tempProperties = new Properties(); + tempProperties.load(new FileInputStream(tempFile)); + fillJavaVersionInfo(versionInfo, tempProperties); } - } catch (IOException e) { + } else { versionInfo.setErrorCode(ERROR_RETURN); - versionInfo.setReason(getText(TextKeys.C_NO_VALID_JAVA, javaHome.getAbsolutePath())); + versionInfo.setReason(getText(TextKeys.C_UNABLE_CREATE_TMPFILE, tempFile.getAbsolutePath())); } - } else { + } catch (IOException e) { versionInfo.setErrorCode(ERROR_RETURN); - versionInfo.setReason(getText(TextKeys.C_NO_JAVA_EXECUTABLE, binDirectory.getAbsolutePath())); + versionInfo.setReason(getText(TextKeys.C_NO_VALID_JAVA, javaHomeHandler.toString())); } } else { versionInfo.setErrorCode(ERROR_RETURN); - versionInfo.setReason(getText(TextKeys.C_NOT_A_DIRECTORY, binDirectory.getAbsolutePath())); + versionInfo.setReason(getText(TextKeys.C_NO_VALID_JAVA, javaHomeHandler.toString())); } return versionInfo; Modified: trunk/installer/src/java/org/python/util/install/InstallerCommandLine.java =================================================================== --- trunk/installer/src/java/org/python/util/install/InstallerCommandLine.java 2008-12-11 05:20:55 UTC (rev 5735) +++ trunk/installer/src/java/org/python/util/install/InstallerCommandLine.java 2008-12-11 09:15:43 UTC (rev 5736) @@ -308,13 +308,14 @@ } /** - * @return the requested java home directory, <code>null</code> if no java home specified + * @return a java home handler for the requested java home directory, or a default handler if no + * java home specified */ - public File getJavaHome() { + public JavaHomeHandler getJavaHomeHandler() { if (hasJavaHomeOption()) { - return new File(_commandLine.getOptionValue(JRE_SHORT)); + return new JavaHomeHandler(_commandLine.getOptionValue(JRE_SHORT)); } else { - return null; + return new JavaHomeHandler(); } } Modified: trunk/installer/src/java/org/python/util/install/JarInstaller.java =================================================================== --- trunk/installer/src/java/org/python/util/install/JarInstaller.java 2008-12-11 05:20:55 UTC (rev 5735) +++ trunk/installer/src/java/org/python/util/install/JarInstaller.java 2008-12-11 09:15:43 UTC (rev 5736) @@ -50,7 +50,7 @@ * @param targetDirectory * @param installationType */ - public void inflate(final File targetDirectory, InstallationType installationType, File javaHome) { + public void inflate(final File targetDirectory, InstallationType installationType, JavaHomeHandler javaHomeHandler) { try { // has to correspond with build.xml // has to correspond with build.Lib.include.properties @@ -144,7 +144,7 @@ if (!installationType.isStandalone()) { // generate start scripts _progressListener.progressStartScripts(); - StartScriptGenerator generator = new StartScriptGenerator(targetDirectory, javaHome); + StartScriptGenerator generator = new StartScriptGenerator(targetDirectory, javaHomeHandler); generator.generateStartScripts(); } else { _progressListener.progressStandalone(); Added: trunk/installer/src/java/org/python/util/install/JavaHomeHandler.java =================================================================== --- trunk/installer/src/java/org/python/util/install/JavaHomeHandler.java (rev 0) +++ trunk/installer/src/java/org/python/util/install/JavaHomeHandler.java 2008-12-11 09:15:43 UTC (rev 5736) @@ -0,0 +1,209 @@ +package org.python.util.install; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + +/** + * Unified entry point for treatment of java.home + * <p> + * Note that the system property <code>java.home</code> is never changed + */ +public final class JavaHomeHandler { + + public static final String JAVA_HOME = "java.home"; + + private static final String JAVA = "java"; + + private static final String JAVA_EXE = "java.exe"; + + private static final String BIN = "bin"; + + private static final String DEFAULT = "_default_"; + + private static final String EMPTY = ""; + + /** + * A map for java home strings and their respective executable names + */ + private static Map<String, String> _executableNames; + + /** + * The current java home + */ + private String _currentJavaHome; + + /** + * create a java home handler for the default java home + */ + public JavaHomeHandler() { + this(DEFAULT); + } + + /** + * create a java home handler for a java home deviation + * + * @param currentJavaHome + * The deviated java home + */ + public JavaHomeHandler(String currentJavaHome) { + setCurrentJavaHome(currentJavaHome); + check(getCurrentJavaHome()); + } + + /** + * get the name of the java executable + * + * @return A name of a java executable which can be passed to {@link ChildProcess} + */ + public String getExecutableName() { + return getExecutableName(getCurrentJavaHome()); + } + + /** + * tell the validity of the current java home + * <p> + * Note: if the current java home is not valid, {@link JavaHomeHandler#getExecutableName()} + * still returns the name of a callable java + * + * @return <code>true</code> if we have a valid java home, <code>false</code> otherwise. + */ + public boolean isValidHome() { + return !getFallbackExecutableName().equals(getExecutableName()); + } + + /** + * get the current java home, if it is valid + * + * @return The current java home + * @throws InstallerException + * if there is no valid java home + * + * @see JavaHomeHandler#isValidHome() + */ + public File getHome() throws InstallerException { + if (!isValidHome()) { + throw new InstallerException("no valid java home"); + } else { + return new File(getCurrentJavaHome()); + } + } + + /** + * @return <code>true</code> if the current java home is a deviation, <code>false</code> + * otherwise + */ + public boolean isDeviation() { + // make sure the default java home is also known + if (!getExecutableNames().containsKey(DEFAULT)) { + check(DEFAULT); + } + return !getExecutableName(DEFAULT).equals(getExecutableName(getCurrentJavaHome())); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(80); + builder.append("["); + if(!isValidHome()) { + builder.append("in"); + } + builder.append("valid java home: "); + builder.append(getCurrentJavaHome()); + builder.append("; executable: "); + builder.append(getExecutableName()); + builder.append("]"); + return builder.toString(); + } + + /** + * reset the handler (clear all stored java homes) + */ + static void reset() { + getExecutableNames().clear(); + } + + private String getExecutableName(String javaHome) { + Map<String, String> executableNames = getExecutableNames(); + if (!executableNames.containsKey(javaHome)) { + check(javaHome); + } + return executableNames.get(javaHome); + } + + private void check(String javaHome) { + boolean valid = false; + boolean isDefault = false; + File javaExecutableFile = null; + if (DEFAULT.equals(javaHome)) { + isDefault = true; + javaHome = System.getProperty(JAVA_HOME, EMPTY); + } + if (javaHome.length() > 0) { + File javaHomeDir = new File(javaHome); + if (javaHomeDir.exists() && javaHomeDir.isDirectory()) { + File binDir = new File(javaHomeDir, BIN); + if (binDir.exists() && binDir.isDirectory()) { + javaExecutableFile = getExecutableFile(binDir); + if (javaExecutableFile.exists()) { + valid = true; + } + } + } + } + if (valid) { + addExecutable(javaHome, javaExecutableFile); + if (isDefault) { + addExecutable(DEFAULT, javaExecutableFile); + if (DEFAULT.equals(getCurrentJavaHome())) { + // update the current home to the real one + setCurrentJavaHome(javaHome); + } + } + } else { + addFallbackExecutable(javaHome); + if (isDefault) { + addFallbackExecutable(DEFAULT); + } + } + } + + private String getFallbackExecutableName() { + return JAVA; + } + + private void addFallbackExecutable(String javaHome) { + getExecutableNames().put(javaHome, getFallbackExecutableName()); + } + + private void addExecutable(String javaHome, File javaExecutableFile) { + getExecutableNames().put(javaHome, javaExecutableFile.getAbsolutePath()); + } + + private File getExecutableFile(File binDir) { + if (Installation.isWindows()) { + return new File(binDir, JAVA_EXE); + } else { + return new File(binDir, JAVA); + } + } + + private static Map<String, String> getExecutableNames() { + if (_executableNames == null) { + _executableNames = new HashMap<String, String>(); + } + return _executableNames; + } + + private String getCurrentJavaHome() { + if (_currentJavaHome == null) { + return DEFAULT; + } else { + return _currentJavaHome; + } + } + + private void setCurrentJavaHome(String currentJavaHome) { + _currentJavaHome = currentJavaHome.trim(); + } +} Modified: trunk/installer/src/java/org/python/util/install/JavaSelectionPage.java =================================================================== --- trunk/installer/src/java/org/python/util/install/JavaSelectionPage.java 2008-12-11 05:20:55 UTC (rev 5735) +++ trunk/installer/src/java/org/python/util/install/JavaSelectionPage.java 2008-12-11 09:15:43 UTC (rev 5736) @@ -20,6 +20,8 @@ public class JavaSelectionPage extends AbstractWizardPage { + private static final long serialVersionUID = 2871052924519223110L; + private final static String _CURRENT_ACTION_COMMAND = "current"; private final static String _OTHER_ACTION_COMMAND = "other"; @@ -123,24 +125,18 @@ protected void beforeValidate() { } - private String getDefaultJavaHome() { - return System.getProperty(JavaVersionTester.JAVA_HOME); - } - private void setValues() { - String javaHome = FrameInstaller.getTargetJavaHome(); boolean current = true; - if (javaHome != null && javaHome.length() > 0) { - if (!javaHome.equals(getDefaultJavaHome())) { - current = false; - } + JavaHomeHandler javaHomeHandler = FrameInstaller.getJavaHomeHandler(); + if (javaHomeHandler.isDeviation()) { + current = false; } setCurrent(current); } private void setCurrent(boolean current) { if (current) { - FrameInstaller.setTargetJavaHome(getDefaultJavaHome()); + FrameInstaller.setJavaHomeHandler(new JavaHomeHandler()); _currentButton.setSelected(true); _otherButton.setSelected(false); _javaHome.setEnabled(false); @@ -151,7 +147,12 @@ _javaHome.setEnabled(true); _browse.setEnabled(true); } - _javaHome.setText(FrameInstaller.getTargetJavaHome()); + JavaHomeHandler javaHomeHandler = FrameInstaller.getJavaHomeHandler(); + if (javaHomeHandler.isValidHome()) { + _javaHome.setText(javaHomeHandler.getHome().getAbsolutePath()); + } else { + _javaHome.setText(""); + } _javaHome.setToolTipText(_javaHome.getText()); } @@ -171,7 +172,7 @@ } int returnValue = fileChooser.showDialog(_browse, getText(SELECT)); if (returnValue == JFileChooser.APPROVE_OPTION) { - FrameInstaller.setTargetJavaHome(fileChooser.getSelectedFile().getAbsolutePath()); + FrameInstaller.setJavaHomeHandler(new JavaHomeHandler(fileChooser.getSelectedFile().getAbsolutePath())); setValues(); } } @@ -189,8 +190,9 @@ } public void focusLost(FocusEvent e) { - FrameInstaller.setTargetJavaHome(_javaHome.getText()); - _javaHome.setToolTipText(_javaHome.getText()); + String javaHome = _javaHome.getText(); + FrameInstaller.setJavaHomeHandler(new JavaHomeHandler(javaHome)); + _javaHome.setToolTipText(javaHome); } } Modified: trunk/installer/src/java/org/python/util/install/JavaSelectionPageValidator.java =================================================================== --- trunk/installer/src/java/org/python/util/install/JavaSelectionPageValidator.java 2008-12-11 05:20:55 UTC (rev 5735) +++ trunk/installer/src/java/org/python/util/install/JavaSelectionPageValidator.java 2008-12-11 09:15:43 UTC (rev 5736) @@ -1,7 +1,5 @@ package org.python.util.install; -import java.io.File; - import org.python.util.install.Installation.JavaVersionInfo; public class JavaSelectionPageValidator extends AbstractWizardValidator { @@ -14,21 +12,19 @@ } protected void validate() throws ValidationException { - String directory = _page.getJavaHome().getText().trim(); // trim to be sure - File javaHome = new File(directory); JavaVersionInfo javaVersionInfo = new JavaVersionInfo(); - String currentJavaHomeName = System.getProperty(JavaVersionTester.JAVA_HOME); - if (currentJavaHomeName.equals(javaHome.getAbsolutePath())) { - // no experiments if current java is selected - Installation.fillJavaVersionInfo(javaVersionInfo, System.getProperties()); - javaHome = new File(currentJavaHomeName); - } else { - javaVersionInfo = Installation.getExternalJavaVersion(javaHome); + String directory = _page.getJavaHome().getText().trim(); // trim to be sure + JavaHomeHandler javaHomeHandler = new JavaHomeHandler(directory); + if(javaHomeHandler.isDeviation()) { + javaVersionInfo = Installation.getExternalJavaVersion(javaHomeHandler); if (javaVersionInfo.getErrorCode() != Installation.NORMAL_RETURN) { throw new ValidationException(javaVersionInfo.getReason()); } + } else { + // no experiments if current java is selected + Installation.fillJavaVersionInfo(javaVersionInfo, System.getProperties()); } - FrameInstaller.setTargetJavaHome(javaHome.getAbsolutePath()); + FrameInstaller.setJavaHomeHandler(javaHomeHandler); FrameInstaller.setJavaVersionInfo(javaVersionInfo); } Modified: trunk/installer/src/java/org/python/util/install/JavaVersionTester.java =================================================================== --- trunk/installer/src/java/org/python/util/install/JavaVersionTester.java 2008-12-11 05:20:55 UTC (rev 5735) +++ trunk/installer/src/java/org/python/util/install/JavaVersionTester.java 2008-12-11 09:15:43 UTC (rev 5736) @@ -27,11 +27,15 @@ System.exit(1); } } else { - System.err.println("problems with temp file " + tempFilePath); + if (!tempFile.exists()) { + System.err.println("temp file " + tempFilePath + " does not exist"); + } else { + System.err.println("cannot write to temp file " + tempFilePath); + } System.exit(1); } } else { - System.err.println("no temp file given"); + System.err.println("no temp file given. usage: JavaVersionTester tempfile"); System.out.println("exiting with 1"); System.exit(1); } @@ -43,7 +47,7 @@ private static String createFileContent() { StringBuffer sb = new StringBuffer(500); - String java_home = System.getProperty(JAVA_HOME, UNKNOWN); + String java_home = new JavaHomeHandler().getExecutableName(); if (File.separatorChar != '/') { java_home = java_home.replace(File.separatorChar, '/'); // backslash would be interpreted as escape char } Modified: trunk/installer/src/java/org/python/util/install/ProgressPage.java =================================================================== --- trunk/installer/src/java/org/python/util/install/ProgressPage.java 2008-12-11 05:20:55 UTC (rev 5735) +++ trunk/installer/src/java/org/python/util/install/ProgressPage.java 2008-12-11 09:15:43 UTC (rev 5736) @@ -13,6 +13,8 @@ public class ProgressPage extends AbstractWizardPage implements ProgressListener { + private static final long serialVersionUID = 9013748834030994976L; + private JarInfo _jarInfo; private JLabel _label; private JProgressBar _progressBar; @@ -78,8 +80,8 @@ jarInstaller.addInstallationListener(_autotest); } File targetDirectory = new File(FrameInstaller.getTargetDirectory()); - File javaHome = new File(FrameInstaller.getTargetJavaHome()); - jarInstaller.inflate(targetDirectory, FrameInstaller.getInstallationType(), javaHome); + JavaHomeHandler javaHomeHandler = FrameInstaller.getJavaHomeHandler(); + jarInstaller.inflate(targetDirectory, FrameInstaller.getInstallationType(), javaHomeHandler); } protected void passivate() { Modified: trunk/installer/src/java/org/python/util/install/StartScriptGenerator.java =================================================================== --- trunk/installer/src/java/org/python/util/install/StartScriptGenerator.java 2008-12-11 05:20:55 UTC (rev 5735) +++ trunk/installer/src/java/org/python/util/install/StartScriptGenerator.java 2008-12-11 09:15:43 UTC (rev 5736) @@ -31,13 +31,13 @@ private File _targetDirectory; - private File _javaHome; + private JavaHomeHandler _javaHomeHandler; private int _flavour; - public StartScriptGenerator(File targetDirectory, File javaHome) { + public StartScriptGenerator(File targetDirectory, JavaHomeHandler javaHomeHandler) { _targetDirectory = targetDirectory; - _javaHome = javaHome; + _javaHomeHandler = javaHomeHandler; if (Installation.isWindows()) { setFlavour(WINDOWS_FLAVOUR); } else { @@ -115,15 +115,13 @@ * * {0} : current date <br> * {1} : user.name <br> - * {2} : java home directory <br> - * {3} : target directory <br> + * {2} : target directory <br> */ private String getStartScript(String template) throws IOException { String parameters[] = new String[4]; parameters[0] = new Date().toString(); parameters[1] = System.getProperty("user.name"); - parameters[2] = _javaHome.getCanonicalPath(); - parameters[3] = getTargetDirectory().getCanonicalPath(); + parameters[2] = getTargetDirectory().getCanonicalPath(); return MessageFormat.format(template, (Object[])parameters); } @@ -136,11 +134,16 @@ StringBuilder builder = getWindowsHeaderTemplate(); builder.append("set "); builder.append(JAVA_HOME); - builder.append("=\"{2}\""); + builder.append("="); + if (_javaHomeHandler.isValidHome()) { + builder.append("\""); + builder.append(_javaHomeHandler.getHome().getAbsolutePath()); + builder.append("\""); + } builder.append(WIN_CR_LF); builder.append("set "); builder.append(JYTHON_HOME_FALLBACK); - builder.append("=\"{3}\""); + builder.append("=\"{2}\""); builder.append(WIN_CR_LF); builder.append(WIN_CR_LF); return builder.toString(); @@ -171,9 +174,15 @@ private String getUnixJythonTemplate() { StringBuilder builder = getUnixHeaderTemplate(); builder.append(JAVA_HOME); + builder.append("="); + if (_javaHomeHandler.isValidHome()) { + builder.append("\""); + builder.append(_javaHomeHandler.getHome().getAbsolutePath()); + builder.append("\""); + } + builder.append("\n"); + builder.append(JYTHON_HOME_FALLBACK); builder.append("=\"{2}\"\n"); - builder.append(JYTHON_HOME_FALLBACK); - builder.append("=\"{3}\"\n"); builder.append("\n"); return builder.toString(); } Modified: trunk/installer/src/java/org/python/util/install/driver/Autotest.java =================================================================== --- trunk/installer/src/java/org/python/util/install/driver/Autotest.java 2008-12-11 05:20:55 UTC (rev 5735) +++ trunk/installer/src/java/org/python/util/install/driver/Autotest.java 2008-12-11 09:15:43 UTC (rev 5736) @@ -6,6 +6,7 @@ import org.python.util.install.FileHelper; import org.python.util.install.InstallationListener; import org.python.util.install.InstallerCommandLine; +import org.python.util.install.JavaHomeHandler; public abstract class Autotest implements InstallationListener { @@ -16,7 +17,7 @@ private String _name; private File _targetDir; - private File _javaHome; + private JavaHomeHandler _javaHomeHandler; private boolean _verbose; private String[] _commandLineArgs; private Verifier _verifier; @@ -36,7 +37,7 @@ createTargetDirectory(); setCommandLineArgs(new String[0]); // a priori value _verbose = commandLine.hasVerboseOption(); - _javaHome = commandLine.getJavaHome(); // null if not present + _javaHomeHandler = commandLine.getJavaHomeHandler(); } /** @@ -77,20 +78,13 @@ } /** - * @return <code>true</code> if this test has a java home deviation + * @return the java home handler, can be asked for deviation using <code>isDeviation()</code>. */ - protected boolean hasJavaHomeDeviation() { - return getJavaHome() != null; + protected JavaHomeHandler getJavaHomeHandler() { + return _javaHomeHandler; } /** - * @return the deviation for java home, <code>null</code> if there is none - */ - protected File getJavaHome() { - return _javaHome; - } - - /** * @return <code>true</code> if this test should be verbose */ protected boolean isVerbose() { @@ -135,9 +129,10 @@ if (isVerbose()) { addArgument("-v"); } - if (hasJavaHomeDeviation()) { + JavaHomeHandler javaHomeHandler = getJavaHomeHandler(); + if (javaHomeHandler.isDeviation() && javaHomeHandler.isValidHome()) { addArgument("-j"); - addArgument(getJavaHome().getAbsolutePath()); + addArgument(javaHomeHandler.getHome().getAbsolutePath()); } } Modified: trunk/installer/src/java/org/python/util/install/driver/InstallationDriver.java =================================================================== --- trunk/installer/src/java/org/python/util/install/driver/InstallationDriver.java 2008-12-11 05:20:55 UTC (rev 5735) +++ trunk/installer/src/java/org/python/util/install/driver/InstallationDriver.java 2008-12-11 09:15:43 UTC (rev 5736) @@ -8,6 +8,7 @@ import org.python.util.install.Installation; import org.python.util.install.InstallerCommandLine; +import org.python.util.install.JavaHomeHandler; public class InstallationDriver { private SilentAutotest[] _silentTests; @@ -186,8 +187,9 @@ test1.addAnswer("3"); // type: minimum test1.addAnswer("n"); // include: nothing test1.addAnswer(test1.getTargetDir().getAbsolutePath()); // target directory - if (test1.hasJavaHomeDeviation()) { - test1.addAnswer(test1.getJavaHome().getAbsolutePath()); // different jre + JavaHomeHandler javaHomeHandler = test1.getJavaHomeHandler(); + if (javaHomeHandler.isDeviation() && javaHomeHandler.isValidHome()) { + test1.addAnswer(javaHomeHandler.getHome().getAbsolutePath()); // different jre } else { test1.addAnswer("=="); // current jre } @@ -214,8 +216,9 @@ test2.addAnswer("wrongAnswer"); // wrong answer test2.addAnswer("n"); // no further excludes test2.addAnswer(test2.getTargetDir().getAbsolutePath()); // target directory - if (test2.hasJavaHomeDeviation()) { - test2.addAnswer(test2.getJavaHome().getAbsolutePath()); // different jre + javaHomeHandler = test2.getJavaHomeHandler(); + if (javaHomeHandler.isDeviation() && javaHomeHandler.isValidHome()) { + test2.addAnswer(javaHomeHandler.getHome().getAbsolutePath()); // different jre } else { test2.addAnswer("=="); // current jre } @@ -233,8 +236,9 @@ test3.addAnswer("y"); // accept license test3.addAnswer("9"); // type: standalone test3.addAnswer(test3.getTargetDir().getAbsolutePath()); // target directory - if (test3.hasJavaHomeDeviation()) { - test3.addAnswer(test3.getJavaHome().getAbsolutePath()); // different jre + javaHomeHandler = test3.getJavaHomeHandler(); + if (javaHomeHandler.isDeviation() && javaHomeHandler.isValidHome()) { + test3.addAnswer(javaHomeHandler.getHome().getAbsolutePath()); // different jre } else { test3.addAnswer("=="); // current jre } @@ -256,8 +260,9 @@ test4.addAnswer("y"); // exclude test4.addAnswer("n"); // no further excludes test4.addAnswer(test4.getTargetDir().getAbsolutePath()); // target directory - if (test4.hasJavaHomeDeviation()) { - test4.addAnswer(test4.getJavaHome().getAbsolutePath()); // different jre + javaHomeHandler = test4.getJavaHomeHandler(); + if (javaHomeHandler.isDeviation() && javaHomeHandler.isValidHome()) { + test4.addAnswer(javaHomeHandler.getHome().getAbsolutePath()); // different jre } else { test4.addAnswer("=="); // current jre } @@ -403,13 +408,15 @@ guiTest.addKeyAction(KeyEvent.VK_TAB); guiTest.addKeyAction(KeyEvent.VK_TAB); guiTest.addKeyAction(KeyEvent.VK_TAB); - if (guiTest.hasJavaHomeDeviation()) { // need 2 more tabs + JavaHomeHandler javaHomeHandler = guiTest.getJavaHomeHandler(); + boolean isValidDeviation = javaHomeHandler.isDeviation() && javaHomeHandler.isValidHome(); + if (isValidDeviation) { // need 2 more tabs guiTest.addKeyAction(KeyEvent.VK_TAB); guiTest.addKeyAction(KeyEvent.VK_TAB); } guiTest.addKeyAction(KeyEvent.VK_SPACE); // overview page - if (guiTest.hasJavaHomeDeviation()) { + if (isValidDeviation) { guiTest.addKeyAction(KeyEvent.VK_SPACE, 3000); // enough time to check the java version } else { guiTest.addKeyAction(KeyEvent.VK_SPACE); Modified: trunk/installer/src/java/org/python/util/install/driver/NormalVerifier.java =================================================================== --- trunk/installer/src/java/org/python/util/install/driver/NormalVerifier.java 2008-12-11 05:20:55 UTC (rev 5735) +++ trunk/installer/src/java/org/python/util/install/driver/NormalVerifier.java 2008-12-11 09:15:43 UTC (rev 5736) @@ -11,7 +11,7 @@ import org.python.util.install.ChildProcess; import org.python.util.install.FileHelper; import org.python.util.install.Installation; -import org.python.util.install.JavaVersionTester; +import org.python.util.install.JavaHomeHandler; public class NormalVerifier implements Verifier { @@ -125,7 +125,11 @@ String template = FileHelper.readAll(inputStream); String targetDirPath = getTargetDir().getCanonicalPath(); String upScriptPath = getSimpleCommand()[1]; - String javaHomeString = System.getProperty(JavaVersionTester.JAVA_HOME, ""); + JavaHomeHandler javaHomeHandler = new JavaHomeHandler(); + String javaHomeString = ""; + if (javaHomeHandler.isValidHome()) { + javaHomeString = javaHomeHandler.getHome().getAbsolutePath(); + } contents = MessageFormat.format(template, targetDirPath, upScriptPath, Modified: trunk/installer/src/java/org/python/util/install/driver/StandaloneVerifier.java =================================================================== --- trunk/installer/src/java/org/python/util/install/driver/StandaloneVerifier.java 2008-12-11 05:20:55 UTC (rev 5735) +++ trunk/installer/src/java/org/python/util/install/driver/StandaloneVerifier.java 2008-12-11 09:15:43 UTC (rev 5736) @@ -6,7 +6,7 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; -import org.python.util.install.JavaVersionTester; +import org.python.util.install.JavaHomeHandler; public class StandaloneVerifier extends NormalVerifier { @@ -30,22 +30,7 @@ throw new DriverException(ioe); } String command[] = new String[4]; - command[0] = null; - String javaHomeString = System.getProperty(JavaVersionTester.JAVA_HOME, null); - if (javaHomeString != null) { - File javaHome = new File(javaHomeString); - if (javaHome.exists()) { - try { - command[0] = javaHome.getCanonicalPath() + File.separator + "bin" - + File.separator + "java"; - } catch (IOException ioe) { - throw new DriverException(ioe); - } - } - } - if (command[0] == null) { - command[0] = "java"; - } + command[0] = new JavaHomeHandler().getExecutableName(); command[1] = "-jar"; command[2] = parentDirName + JYTHON_JAR; command[3] = parentDirName + AUTOTEST_PY; Modified: trunk/installer/test/java/org/python/util/install/FrameInstallerTest.java =================================================================== --- trunk/installer/test/java/org/python/util/install/FrameInstallerTest.java 2008-12-11 05:20:55 UTC (rev 5735) +++ trunk/installer/test/java/org/python/util/install/FrameInstallerTest.java 2008-12-11 09:15:43 UTC (rev 5736) @@ -60,4 +60,14 @@ assertFalse(returnedType.installDocumentation()); assertFalse(returnedType.installSources()); } + + public void testSetGetJavaHomeHandler() { + assertNotNull(FrameInstaller.getJavaHomeHandler()); + JavaHomeHandler handler1 = new JavaHomeHandler(); + JavaHomeHandler handler2 = new JavaHomeHandler("some/dir"); + FrameInstaller.setJavaHomeHandler(handler1); + assertEquals(handler1, FrameInstaller.getJavaHomeHandler()); + FrameInstaller.setJavaHomeHandler(handler2); + assertEquals(handler2, FrameInstaller.getJavaHomeHandler()); + } } Modified: trunk/installer/test/java/org/python/util/install/InstallationTest.java =================================================================== --- trunk/installer/test/java/org/python/util/install/InstallationTest.java 2008-12-11 05:20:55 UTC (rev 5735) +++ trunk/insta... [truncated message content] |
From: <pj...@us...> - 2008-12-11 05:20:59
|
Revision: 5735 http://jython.svn.sourceforge.net/jython/?rev=5735&view=rev Author: pjenvey Date: 2008-12-11 05:20:55 +0000 (Thu, 11 Dec 2008) Log Message: ----------- o fix imp.find_module not finding builtin modules o add __builtin__ and sys to sys.builtin_module_names and another hack for re-importing __builtin__ like we have for sys fixes #1161 thanks Sven Reimers Modified Paths: -------------- trunk/jython/Lib/test/test_import_jy.py trunk/jython/src/org/python/core/PySystemState.java trunk/jython/src/org/python/core/imp.java trunk/jython/src/org/python/modules/imp.java Modified: trunk/jython/Lib/test/test_import_jy.py =================================================================== --- trunk/jython/Lib/test/test_import_jy.py 2008-12-11 00:39:49 UTC (rev 5734) +++ trunk/jython/Lib/test/test_import_jy.py 2008-12-11 05:20:55 UTC (rev 5735) @@ -90,6 +90,7 @@ self.assertEquals(bytecode, read(init_compiled), 'bytecode was recompiled') + class OverrideBuiltinsImportTestCase(unittest.TestCase): def test_override(self): tests = [ @@ -127,9 +128,19 @@ finally: __builtin__.__import__ = oldimp +class ImpTestCase(unittest.TestCase): + + def test_imp_find_module_builtins(self): + self.assertEqual(imp.find_module('sys'), (None, 'sys', ('', '', 6))) + self.assertEqual(imp.find_module('__builtin__'), + (None, '__builtin__', ('', '', 6))) + self.assertEqual(imp.find_module('imp'), (None, 'imp', ('', '', 6))) + + def test_main(): - test_classes = [MislabeledImportTestCase, OverrideBuiltinsImportTestCase] - test_support.run_unittest(*test_classes) + test_support.run_unittest(MislabeledImportTestCase, + OverrideBuiltinsImportTestCase, + ImpTestCase) if __name__ == '__main__': test_main() Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2008-12-11 00:39:49 UTC (rev 5734) +++ trunk/jython/src/org/python/core/PySystemState.java 2008-12-11 05:20:55 UTC (rev 5735) @@ -709,6 +709,10 @@ private static void initBuiltins(Properties props) { builtinNames = new Hashtable(); + // add the oddball builtins that are specially handled + builtinNames.put("__builtin__", ""); + builtinNames.put("sys", ""); + // add builtins specified in the Setup.java file for (int i=0; i < Setup.builtinModules.length; i++) addBuiltin(Setup.builtinModules[i]); @@ -727,7 +731,7 @@ builtin_module_names = new PyTuple(built_mod); } - static String getBuiltin(String name) { + public static String getBuiltin(String name) { return (String)builtinNames.get(name); } Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2008-12-11 00:39:49 UTC (rev 5734) +++ trunk/jython/src/org/python/core/imp.java 2008-12-11 05:20:55 UTC (rev 5735) @@ -389,10 +389,13 @@ private static PyObject loadBuiltin(String name) { if (name == "sys") { - Py.writeComment(IMPORT_LOG, "'" + name + "' as sys in " - + "builtin modules"); + Py.writeComment(IMPORT_LOG, "'" + name + "' as sys in builtin modules"); return Py.java2py(Py.getSystemState()); } + if (name == "__builtin__") { + Py.writeComment(IMPORT_LOG, "'" + name + "' as __builtin__ in builtin modules"); + return new PyModule("__builtin__", PySystemState.builtins); + } String mod = PySystemState.getBuiltin(name); if (mod != null) { Class c = Py.findClassEx(mod, "builtin modules"); Modified: trunk/jython/src/org/python/modules/imp.java =================================================================== --- trunk/jython/src/org/python/modules/imp.java 2008-12-11 00:39:49 UTC (rev 5734) +++ trunk/jython/src/org/python/modules/imp.java 2008-12-11 05:20:55 UTC (rev 5735) @@ -129,10 +129,6 @@ return null; } - public static PyObject find_module(String name) { - return find_module(name, null); - } - public static PyObject load_source(String modname, String filename) { return load_source(modname, filename, null); } @@ -158,11 +154,20 @@ return mod; } + public static PyObject find_module(String name) { + return find_module(name, Py.None); + } + public static PyObject find_module(String name, PyObject path) { - if (path == null || path == Py.None) { + if (path == Py.None && PySystemState.getBuiltin(name) != null) { + return new PyTuple(Py.None, Py.newString(name), + new PyTuple(Py.EmptyString, Py.EmptyString, + Py.newInteger(C_BUILTIN))); + } + + if (path == Py.None) { path = Py.getSystemState().path; } - for (PyObject p : path.asIterable()) { ModuleInfo mi = findFromSource(name, p.toString(), false, true); if(mi == null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-12-11 00:39:52
|
Revision: 5734 http://jython.svn.sourceforge.net/jython/?rev=5734&view=rev Author: pjenvey Date: 2008-12-11 00:39:49 +0000 (Thu, 11 Dec 2008) Log Message: ----------- COMPUTE_FRAMES implies COMPUTE_MAXS Modified Paths: -------------- trunk/jython/src/org/python/compiler/ClassFile.java Modified: trunk/jython/src/org/python/compiler/ClassFile.java =================================================================== --- trunk/jython/src/org/python/compiler/ClassFile.java 2008-12-11 00:10:25 UTC (rev 5733) +++ trunk/jython/src/org/python/compiler/ClassFile.java 2008-12-11 00:39:49 UTC (rev 5734) @@ -46,7 +46,7 @@ this.interfaces = new String[0]; this.access = access; - cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); + cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); methodVisitors = Collections.synchronizedList(new ArrayList()); fieldVisitors = Collections.synchronizedList(new ArrayList()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-12-11 00:10:27
|
Revision: 5733 http://jython.svn.sourceforge.net/jython/?rev=5733&view=rev Author: pjenvey Date: 2008-12-11 00:10:25 +0000 (Thu, 11 Dec 2008) Log Message: ----------- fail fast when path exists but isn't a normal file suggested by Ethan Glasser-Camp fixes #1199 Modified Paths: -------------- trunk/jython/src/org/python/modules/zipimport/zipimporter.java Modified: trunk/jython/src/org/python/modules/zipimport/zipimporter.java =================================================================== --- trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2008-12-10 08:23:53 UTC (rev 5732) +++ trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2008-12-11 00:10:25 UTC (rev 5733) @@ -115,8 +115,10 @@ prefix = ""; while (true) { File fullPathFile = new File(sys.getPath(pathFile.getPath())); - if (fullPathFile.isFile()) { - archive = pathFile.getPath(); + if (fullPathFile.exists()) { + if (fullPathFile.isFile()) { + archive = pathFile.getPath(); + } break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-10 08:24:02
|
Revision: 5732 http://jython.svn.sourceforge.net/jython/?rev=5732&view=rev Author: cgroves Date: 2008-12-10 08:23:53 +0000 (Wed, 10 Dec 2008) Log Message: ----------- Merged revisions 5670,5680-5682,5687,5691,5695-5697,5702-5704,5706,5712-5726 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython I removed a bunch of unused imports of PyJavaInstance in the ast code and ripped out all the collection updates as they landed separately in PyJavaType. ........ r5670 | nriley | 2008-12-01 10:33:00 -0800 (Mon, 01 Dec 2008) | 1 line PyStringMap should not be hashable, just as PyDictionary isn't. ........ r5680 | otmarhumbel | 2008-12-03 01:30:15 -0800 (Wed, 03 Dec 2008) | 5 lines prevent JYTHON_OPTS from being enriched with arguments (this could lead to an infinite recursion of subprocesses) test_subprocess_jy.py now passes issue #1187 is fixed now ........ r5681 | nriley | 2008-12-03 01:39:46 -0800 (Wed, 03 Dec 2008) | 1 line --print option for start script ........ r5682 | otmarhumbel | 2008-12-03 06:43:11 -0800 (Wed, 03 Dec 2008) | 1 line added tests for issue #1187 ........ r5687 | nriley | 2008-12-03 14:08:15 -0800 (Wed, 03 Dec 2008) | 1 line avoid test_asynchat on Windows too; refs #1064 ........ r5691 | fwierzbicki | 2008-12-03 18:20:28 -0800 (Wed, 03 Dec 2008) | 3 lines Initialized merge tracking via "svnmerge" with revisions "1-5585" from https://jython.svn.sourceforge.net/svnroot/jython/branches/astwrite ........ r5695 | fwierzbicki | 2008-12-04 17:10:49 -0800 (Thu, 04 Dec 2008) | 13 lines Merging the astwrite branch into trunk. While I was testing, I noticed some problems stemming from the package names and the "Type" at the end of some of the asdl_antlr.py generated code -- so I fixed that up as well. This checkin changes all of the access on ast nodes to be getters and setters with Lists instead of arrays. The ast nodes also now descend from PyObject instead of Antlr's CommonTree. There are new adapter classes that handle the back and forth of ast nodes from Java to Python. Merged revisions 5586-5592,5594-5595,5597,5612,5628,5633-5634,5636-5637,5641-5643,5660,5672,5677-5679,5683,5685-5686 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/branches/astwrite ........ r5696 | fwierzbicki | 2008-12-04 17:11:47 -0800 (Thu, 04 Dec 2008) | 2 lines Ack missed these new files for the astwrite merge. ........ r5697 | fwierzbicki | 2008-12-04 19:33:30 -0800 (Thu, 04 Dec 2008) | 2 lines Fix missing exposed classes. ........ r5702 | fwierzbicki | 2008-12-05 06:26:10 -0800 (Fri, 05 Dec 2008) | 2 lines Derived classes for org/python/antlr/ast/* ........ r5703 | fwierzbicki | 2008-12-05 08:10:15 -0800 (Fri, 05 Dec 2008) | 2 lines org/python/antlr/op/* Derived classes, and fixed lineno, col_offset from ast_antlr.py ........ r5704 | nriley | 2008-12-05 10:43:33 -0800 (Fri, 05 Dec 2008) | 1 line avoid test_asynchat on Solaris (everywhere but Linux?); refs #1064 ........ r5706 | fwierzbicki | 2008-12-05 18:49:45 -0800 (Fri, 05 Dec 2008) | 3 lines Added better lineno and col_offset support to a couple of ast nodes, also finished slice support in AstList. ........ r5712 | pjenvey | 2008-12-05 22:52:28 -0800 (Fri, 05 Dec 2008) | 4 lines o fix str/unicode add/join to decode when appropriate o fix '%r' % u'' returning unicode o cast fastSequence to a PySequence ........ r5713 | pjenvey | 2008-12-05 22:55:48 -0800 (Fri, 05 Dec 2008) | 1 line correct mismatch between partition/rpartition and their exposed versions ........ r5714 | pjenvey | 2008-12-06 01:02:53 -0800 (Sat, 06 Dec 2008) | 1 line revert the astlist workaround as it subclasses list now ........ r5715 | fwierzbicki | 2008-12-06 07:00:08 -0800 (Sat, 06 Dec 2008) | 5 lines Now able to use the exact copy of CPython's ast.py Copied from: http://svn.python.org/projects/python/branches/release26-maint/Lib/ast.py ........ r5716 | otmarhumbel | 2008-12-06 13:44:53 -0800 (Sat, 06 Dec 2008) | 2 lines fork the biggest javac task this hopefully enables hudson's build ........ r5717 | otmarhumbel | 2008-12-06 14:14:43 -0800 (Sat, 06 Dec 2008) | 1 line javac ignores the optimize option, according to http://ant.apache.org/manual/ ........ r5718 | nriley | 2008-12-06 14:50:19 -0800 (Sat, 06 Dec 2008) | 1 line Java 6 javac on Mac OS X requires more memory to compile Jython ........ r5719 | fwierzbicki | 2008-12-06 20:15:26 -0800 (Sat, 06 Dec 2008) | 2 lines Fixed bugs in mutable ast revealed by running sympy tests. ........ r5720 | nriley | 2008-12-06 22:35:04 -0800 (Sat, 06 Dec 2008) | 1 line Java 6 javac on x64 Linux requires even more memory to compile Jython ........ r5721 | fwierzbicki | 2008-12-07 10:57:27 -0800 (Sun, 07 Dec 2008) | 2 lines A couple more missed adaptations revealed by sympy testing. ........ r5722 | pjenvey | 2008-12-08 11:44:12 -0800 (Mon, 08 Dec 2008) | 2 lines use hex idstrs (without any padding) to more closely resemble CPython ........ r5723 | pjenvey | 2008-12-09 00:45:33 -0800 (Tue, 09 Dec 2008) | 3 lines avoid an NPE when getSQLState is null thanks Matthew Harrison ........ r5724 | pjenvey | 2008-12-09 13:56:51 -0800 (Tue, 09 Dec 2008) | 8 lines o allow overriding of ExceptionHandler's inline finally block o fix the with statement's normal finally/exit block so it also happens for non local gotos (e.g. return, continue) o modify test_with instead of adding test_with_jy to test for this case -- the lack of these tests is really a test bug IMO fixes #1194 pointed out by Terrence Cole ........ r5725 | pjenvey | 2008-12-09 14:25:56 -0800 (Tue, 09 Dec 2008) | 1 line these are no longer used ........ r5726 | pjenvey | 2008-12-09 16:07:22 -0800 (Tue, 09 Dec 2008) | 4 lines match CPython's dir() more closely fixes #1196 pointed out by doublep ........ Modified Paths: -------------- branches/newstyle-java-types/CoreExposed.includes branches/newstyle-java-types/Lib/ast.py branches/newstyle-java-types/Lib/inspect.py branches/newstyle-java-types/Lib/test/test_ast.py branches/newstyle-java-types/Lib/test/test_asynchat.py branches/newstyle-java-types/Lib/test/test_builtin_jy.py branches/newstyle-java-types/Lib/test/test_stringmap.py branches/newstyle-java-types/Lib/test/test_subprocess_jy.py branches/newstyle-java-types/Lib/test/test_unicode_jy.py branches/newstyle-java-types/Lib/test/test_with.py branches/newstyle-java-types/ast/Python.asdl branches/newstyle-java-types/ast/asdl_antlr.py branches/newstyle-java-types/build.xml branches/newstyle-java-types/grammar/Python.g branches/newstyle-java-types/src/com/ziclix/python/sql/zxJDBC.java branches/newstyle-java-types/src/org/python/antlr/AST.java branches/newstyle-java-types/src/org/python/antlr/ErrorHandler.java branches/newstyle-java-types/src/org/python/antlr/ExpressionParser.java branches/newstyle-java-types/src/org/python/antlr/FailFastHandler.java branches/newstyle-java-types/src/org/python/antlr/GrammarActions.java branches/newstyle-java-types/src/org/python/antlr/InteractiveParser.java branches/newstyle-java-types/src/org/python/antlr/ListErrorHandler.java branches/newstyle-java-types/src/org/python/antlr/ModuleParser.java branches/newstyle-java-types/src/org/python/antlr/PythonTree.java branches/newstyle-java-types/src/org/python/antlr/ast/Assert.java branches/newstyle-java-types/src/org/python/antlr/ast/Assign.java branches/newstyle-java-types/src/org/python/antlr/ast/Attribute.java branches/newstyle-java-types/src/org/python/antlr/ast/AugAssign.java branches/newstyle-java-types/src/org/python/antlr/ast/BinOp.java branches/newstyle-java-types/src/org/python/antlr/ast/BoolOp.java branches/newstyle-java-types/src/org/python/antlr/ast/Break.java branches/newstyle-java-types/src/org/python/antlr/ast/Call.java branches/newstyle-java-types/src/org/python/antlr/ast/ClassDef.java branches/newstyle-java-types/src/org/python/antlr/ast/Compare.java branches/newstyle-java-types/src/org/python/antlr/ast/Continue.java branches/newstyle-java-types/src/org/python/antlr/ast/Delete.java branches/newstyle-java-types/src/org/python/antlr/ast/Dict.java branches/newstyle-java-types/src/org/python/antlr/ast/Ellipsis.java branches/newstyle-java-types/src/org/python/antlr/ast/ErrorExpr.java branches/newstyle-java-types/src/org/python/antlr/ast/ErrorMod.java branches/newstyle-java-types/src/org/python/antlr/ast/ErrorSlice.java branches/newstyle-java-types/src/org/python/antlr/ast/ErrorStmt.java branches/newstyle-java-types/src/org/python/antlr/ast/Exec.java branches/newstyle-java-types/src/org/python/antlr/ast/Expr.java branches/newstyle-java-types/src/org/python/antlr/ast/Expression.java branches/newstyle-java-types/src/org/python/antlr/ast/ExtSlice.java branches/newstyle-java-types/src/org/python/antlr/ast/For.java branches/newstyle-java-types/src/org/python/antlr/ast/FunctionDef.java branches/newstyle-java-types/src/org/python/antlr/ast/GeneratorExp.java branches/newstyle-java-types/src/org/python/antlr/ast/Global.java branches/newstyle-java-types/src/org/python/antlr/ast/If.java branches/newstyle-java-types/src/org/python/antlr/ast/IfExp.java branches/newstyle-java-types/src/org/python/antlr/ast/Import.java branches/newstyle-java-types/src/org/python/antlr/ast/ImportFrom.java branches/newstyle-java-types/src/org/python/antlr/ast/Index.java branches/newstyle-java-types/src/org/python/antlr/ast/Interactive.java branches/newstyle-java-types/src/org/python/antlr/ast/Lambda.java branches/newstyle-java-types/src/org/python/antlr/ast/List.java branches/newstyle-java-types/src/org/python/antlr/ast/ListComp.java branches/newstyle-java-types/src/org/python/antlr/ast/Module.java branches/newstyle-java-types/src/org/python/antlr/ast/Name.java branches/newstyle-java-types/src/org/python/antlr/ast/Num.java branches/newstyle-java-types/src/org/python/antlr/ast/Pass.java branches/newstyle-java-types/src/org/python/antlr/ast/Print.java branches/newstyle-java-types/src/org/python/antlr/ast/Raise.java branches/newstyle-java-types/src/org/python/antlr/ast/Repr.java branches/newstyle-java-types/src/org/python/antlr/ast/Return.java branches/newstyle-java-types/src/org/python/antlr/ast/Slice.java branches/newstyle-java-types/src/org/python/antlr/ast/Str.java branches/newstyle-java-types/src/org/python/antlr/ast/Subscript.java branches/newstyle-java-types/src/org/python/antlr/ast/Suite.java branches/newstyle-java-types/src/org/python/antlr/ast/TryExcept.java branches/newstyle-java-types/src/org/python/antlr/ast/TryFinally.java branches/newstyle-java-types/src/org/python/antlr/ast/Tuple.java branches/newstyle-java-types/src/org/python/antlr/ast/UnaryOp.java branches/newstyle-java-types/src/org/python/antlr/ast/VisitorBase.java branches/newstyle-java-types/src/org/python/antlr/ast/VisitorIF.java branches/newstyle-java-types/src/org/python/antlr/ast/While.java branches/newstyle-java-types/src/org/python/antlr/ast/With.java branches/newstyle-java-types/src/org/python/antlr/ast/Yield.java branches/newstyle-java-types/src/org/python/antlr/ast/boolopType.java branches/newstyle-java-types/src/org/python/antlr/ast/cmpopType.java branches/newstyle-java-types/src/org/python/antlr/ast/expr_contextType.java branches/newstyle-java-types/src/org/python/antlr/ast/operatorType.java branches/newstyle-java-types/src/org/python/antlr/ast/unaryopType.java branches/newstyle-java-types/src/org/python/compiler/ArgListCompiler.java branches/newstyle-java-types/src/org/python/compiler/CodeCompiler.java branches/newstyle-java-types/src/org/python/compiler/Future.java branches/newstyle-java-types/src/org/python/compiler/Module.java branches/newstyle-java-types/src/org/python/compiler/ProxyMaker.java branches/newstyle-java-types/src/org/python/compiler/ScopeInfo.java branches/newstyle-java-types/src/org/python/compiler/ScopesCompiler.java branches/newstyle-java-types/src/org/python/core/AbstractArray.java branches/newstyle-java-types/src/org/python/core/IdImpl.java branches/newstyle-java-types/src/org/python/core/ParserFacade.java branches/newstyle-java-types/src/org/python/core/Py.java branches/newstyle-java-types/src/org/python/core/PyClass.java branches/newstyle-java-types/src/org/python/core/PyInstance.java branches/newstyle-java-types/src/org/python/core/PyList.java branches/newstyle-java-types/src/org/python/core/PyObject.java branches/newstyle-java-types/src/org/python/core/PySequence.java branches/newstyle-java-types/src/org/python/core/PyString.java branches/newstyle-java-types/src/org/python/core/PyStringMap.java branches/newstyle-java-types/src/org/python/core/PyType.java branches/newstyle-java-types/src/org/python/core/PyUnicode.java branches/newstyle-java-types/src/org/python/core/__builtin__.java branches/newstyle-java-types/src/org/python/core/imp.java branches/newstyle-java-types/src/org/python/modules/Setup.java branches/newstyle-java-types/src/shell/jython branches/newstyle-java-types/src/shell/jython.bat branches/newstyle-java-types/src/templates/mappings Added Paths: ----------- branches/newstyle-java-types/src/org/python/antlr/adapter/ branches/newstyle-java-types/src/org/python/antlr/adapter/AliasAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/AstAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/AstAdapters.java branches/newstyle-java-types/src/org/python/antlr/adapter/CmpopAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/ComprehensionAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/ExcepthandlerAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/ExprAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/IdentifierAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/KeywordAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/SliceAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/StmtAdapter.java branches/newstyle-java-types/src/org/python/antlr/ast/AssertDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/AssignDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/AstModule.java branches/newstyle-java-types/src/org/python/antlr/ast/AttributeDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/AugAssignDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/BinOpDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/BoolOpDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/BreakDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/CallDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/ClassDefDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/CompareDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/ContinueDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/DeleteDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/DictDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/EllipsisDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/ExceptHandler.java branches/newstyle-java-types/src/org/python/antlr/ast/ExceptHandlerDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/ExecDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/ExprDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/ExpressionDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/ExtSliceDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/ForDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/FunctionDefDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/GeneratorExpDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/GlobalDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/IfDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/IfExpDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/ImportDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/ImportFromDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/IndexDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/InteractiveDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/LambdaDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/ListCompDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/ListDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/ModuleDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/NameDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/NumDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/PassDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/PrintDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/RaiseDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/ReprDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/ReturnDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/SliceDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/StrDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/SubscriptDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/SuiteDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/TryExceptDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/TryFinallyDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/TupleDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/UnaryOpDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/WhileDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/WithDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/YieldDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/alias.java branches/newstyle-java-types/src/org/python/antlr/ast/aliasDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/arguments.java branches/newstyle-java-types/src/org/python/antlr/ast/argumentsDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/comprehension.java branches/newstyle-java-types/src/org/python/antlr/ast/comprehensionDerived.java branches/newstyle-java-types/src/org/python/antlr/ast/keyword.java branches/newstyle-java-types/src/org/python/antlr/ast/keywordDerived.java branches/newstyle-java-types/src/org/python/antlr/base/ branches/newstyle-java-types/src/org/python/antlr/base/excepthandler.java branches/newstyle-java-types/src/org/python/antlr/base/expr.java branches/newstyle-java-types/src/org/python/antlr/base/mod.java branches/newstyle-java-types/src/org/python/antlr/base/slice.java branches/newstyle-java-types/src/org/python/antlr/base/stmt.java branches/newstyle-java-types/src/org/python/antlr/op/ branches/newstyle-java-types/src/org/python/antlr/op/Add.java branches/newstyle-java-types/src/org/python/antlr/op/AddDerived.java branches/newstyle-java-types/src/org/python/antlr/op/And.java branches/newstyle-java-types/src/org/python/antlr/op/AndDerived.java branches/newstyle-java-types/src/org/python/antlr/op/AugLoad.java branches/newstyle-java-types/src/org/python/antlr/op/AugLoadDerived.java branches/newstyle-java-types/src/org/python/antlr/op/AugStore.java branches/newstyle-java-types/src/org/python/antlr/op/AugStoreDerived.java branches/newstyle-java-types/src/org/python/antlr/op/BitAnd.java branches/newstyle-java-types/src/org/python/antlr/op/BitAndDerived.java branches/newstyle-java-types/src/org/python/antlr/op/BitOr.java branches/newstyle-java-types/src/org/python/antlr/op/BitOrDerived.java branches/newstyle-java-types/src/org/python/antlr/op/BitXor.java branches/newstyle-java-types/src/org/python/antlr/op/BitXorDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Del.java branches/newstyle-java-types/src/org/python/antlr/op/DelDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Div.java branches/newstyle-java-types/src/org/python/antlr/op/DivDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Eq.java branches/newstyle-java-types/src/org/python/antlr/op/EqDerived.java branches/newstyle-java-types/src/org/python/antlr/op/FloorDiv.java branches/newstyle-java-types/src/org/python/antlr/op/FloorDivDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Gt.java branches/newstyle-java-types/src/org/python/antlr/op/GtDerived.java branches/newstyle-java-types/src/org/python/antlr/op/GtE.java branches/newstyle-java-types/src/org/python/antlr/op/GtEDerived.java branches/newstyle-java-types/src/org/python/antlr/op/In.java branches/newstyle-java-types/src/org/python/antlr/op/InDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Invert.java branches/newstyle-java-types/src/org/python/antlr/op/InvertDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Is.java branches/newstyle-java-types/src/org/python/antlr/op/IsDerived.java branches/newstyle-java-types/src/org/python/antlr/op/IsNot.java branches/newstyle-java-types/src/org/python/antlr/op/IsNotDerived.java branches/newstyle-java-types/src/org/python/antlr/op/LShift.java branches/newstyle-java-types/src/org/python/antlr/op/LShiftDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Load.java branches/newstyle-java-types/src/org/python/antlr/op/LoadDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Lt.java branches/newstyle-java-types/src/org/python/antlr/op/LtDerived.java branches/newstyle-java-types/src/org/python/antlr/op/LtE.java branches/newstyle-java-types/src/org/python/antlr/op/LtEDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Mod.java branches/newstyle-java-types/src/org/python/antlr/op/ModDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Mult.java branches/newstyle-java-types/src/org/python/antlr/op/MultDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Not.java branches/newstyle-java-types/src/org/python/antlr/op/NotDerived.java branches/newstyle-java-types/src/org/python/antlr/op/NotEq.java branches/newstyle-java-types/src/org/python/antlr/op/NotEqDerived.java branches/newstyle-java-types/src/org/python/antlr/op/NotIn.java branches/newstyle-java-types/src/org/python/antlr/op/NotInDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Or.java branches/newstyle-java-types/src/org/python/antlr/op/OrDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Param.java branches/newstyle-java-types/src/org/python/antlr/op/ParamDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Pow.java branches/newstyle-java-types/src/org/python/antlr/op/PowDerived.java branches/newstyle-java-types/src/org/python/antlr/op/RShift.java branches/newstyle-java-types/src/org/python/antlr/op/RShiftDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Store.java branches/newstyle-java-types/src/org/python/antlr/op/StoreDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Sub.java branches/newstyle-java-types/src/org/python/antlr/op/SubDerived.java branches/newstyle-java-types/src/org/python/antlr/op/UAdd.java branches/newstyle-java-types/src/org/python/antlr/op/UAddDerived.java branches/newstyle-java-types/src/org/python/antlr/op/USub.java branches/newstyle-java-types/src/org/python/antlr/op/USubDerived.java branches/newstyle-java-types/src/org/python/core/AstList.java branches/newstyle-java-types/src/templates/ast_Assert.derived branches/newstyle-java-types/src/templates/ast_Assign.derived branches/newstyle-java-types/src/templates/ast_Attribute.derived branches/newstyle-java-types/src/templates/ast_AugAssign.derived branches/newstyle-java-types/src/templates/ast_BinOp.derived branches/newstyle-java-types/src/templates/ast_BoolOp.derived branches/newstyle-java-types/src/templates/ast_Break.derived branches/newstyle-java-types/src/templates/ast_Call.derived branches/newstyle-java-types/src/templates/ast_ClassDef.derived branches/newstyle-java-types/src/templates/ast_Compare.derived branches/newstyle-java-types/src/templates/ast_Continue.derived branches/newstyle-java-types/src/templates/ast_Delete.derived branches/newstyle-java-types/src/templates/ast_Dict.derived branches/newstyle-java-types/src/templates/ast_Ellipsis.derived branches/newstyle-java-types/src/templates/ast_ExceptHandler.derived branches/newstyle-java-types/src/templates/ast_Exec.derived branches/newstyle-java-types/src/templates/ast_Expr.derived branches/newstyle-java-types/src/templates/ast_Expression.derived branches/newstyle-java-types/src/templates/ast_ExtSlice.derived branches/newstyle-java-types/src/templates/ast_For.derived branches/newstyle-java-types/src/templates/ast_FunctionDef.derived branches/newstyle-java-types/src/templates/ast_GeneratorExp.derived branches/newstyle-java-types/src/templates/ast_Global.derived branches/newstyle-java-types/src/templates/ast_If.derived branches/newstyle-java-types/src/templates/ast_IfExp.derived branches/newstyle-java-types/src/templates/ast_Import.derived branches/newstyle-java-types/src/templates/ast_ImportFrom.derived branches/newstyle-java-types/src/templates/ast_Index.derived branches/newstyle-java-types/src/templates/ast_Interactive.derived branches/newstyle-java-types/src/templates/ast_Lambda.derived branches/newstyle-java-types/src/templates/ast_List.derived branches/newstyle-java-types/src/templates/ast_ListComp.derived branches/newstyle-java-types/src/templates/ast_Module.derived branches/newstyle-java-types/src/templates/ast_Name.derived branches/newstyle-java-types/src/templates/ast_Num.derived branches/newstyle-java-types/src/templates/ast_Pass.derived branches/newstyle-java-types/src/templates/ast_Print.derived branches/newstyle-java-types/src/templates/ast_Raise.derived branches/newstyle-java-types/src/templates/ast_Repr.derived branches/newstyle-java-types/src/templates/ast_Return.derived branches/newstyle-java-types/src/templates/ast_Slice.derived branches/newstyle-java-types/src/templates/ast_Str.derived branches/newstyle-java-types/src/templates/ast_Subscript.derived branches/newstyle-java-types/src/templates/ast_Suite.derived branches/newstyle-java-types/src/templates/ast_TryExcept.derived branches/newstyle-java-types/src/templates/ast_TryFinally.derived branches/newstyle-java-types/src/templates/ast_Tuple.derived branches/newstyle-java-types/src/templates/ast_UnaryOp.derived branches/newstyle-java-types/src/templates/ast_While.derived branches/newstyle-java-types/src/templates/ast_With.derived branches/newstyle-java-types/src/templates/ast_Yield.derived branches/newstyle-java-types/src/templates/ast_alias.derived branches/newstyle-java-types/src/templates/ast_arguments.derived branches/newstyle-java-types/src/templates/ast_comprehension.derived branches/newstyle-java-types/src/templates/ast_keyword.derived branches/newstyle-java-types/src/templates/op_Add.derived branches/newstyle-java-types/src/templates/op_And.derived branches/newstyle-java-types/src/templates/op_AugLoad.derived branches/newstyle-java-types/src/templates/op_AugStore.derived branches/newstyle-java-types/src/templates/op_BitAnd.derived branches/newstyle-java-types/src/templates/op_BitOr.derived branches/newstyle-java-types/src/templates/op_BitXor.derived branches/newstyle-java-types/src/templates/op_Del.derived branches/newstyle-java-types/src/templates/op_Div.derived branches/newstyle-java-types/src/templates/op_Eq.derived branches/newstyle-java-types/src/templates/op_FloorDiv.derived branches/newstyle-java-types/src/templates/op_Gt.derived branches/newstyle-java-types/src/templates/op_GtE.derived branches/newstyle-java-types/src/templates/op_In.derived branches/newstyle-java-types/src/templates/op_Invert.derived branches/newstyle-java-types/src/templates/op_Is.derived branches/newstyle-java-types/src/templates/op_IsNot.derived branches/newstyle-java-types/src/templates/op_LShift.derived branches/newstyle-java-types/src/templates/op_Load.derived branches/newstyle-java-types/src/templates/op_Lt.derived branches/newstyle-java-types/src/templates/op_LtE.derived branches/newstyle-java-types/src/templates/op_Mod.derived branches/newstyle-java-types/src/templates/op_Mult.derived branches/newstyle-java-types/src/templates/op_Not.derived branches/newstyle-java-types/src/templates/op_NotEq.derived branches/newstyle-java-types/src/templates/op_NotIn.derived branches/newstyle-java-types/src/templates/op_Or.derived branches/newstyle-java-types/src/templates/op_Param.derived branches/newstyle-java-types/src/templates/op_Pow.derived branches/newstyle-java-types/src/templates/op_RShift.derived branches/newstyle-java-types/src/templates/op_Store.derived branches/newstyle-java-types/src/templates/op_Sub.derived branches/newstyle-java-types/src/templates/op_UAdd.derived branches/newstyle-java-types/src/templates/op_USub.derived Removed Paths: ------------- branches/newstyle-java-types/Lib/_ast.py branches/newstyle-java-types/src/org/python/antlr/adapter/AliasAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/AstAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/AstAdapters.java branches/newstyle-java-types/src/org/python/antlr/adapter/CmpopAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/ComprehensionAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/ExcepthandlerAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/ExprAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/IdentifierAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/KeywordAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/SliceAdapter.java branches/newstyle-java-types/src/org/python/antlr/adapter/StmtAdapter.java branches/newstyle-java-types/src/org/python/antlr/ast/aliasType.java branches/newstyle-java-types/src/org/python/antlr/ast/argumentsType.java branches/newstyle-java-types/src/org/python/antlr/ast/comprehensionType.java branches/newstyle-java-types/src/org/python/antlr/ast/excepthandlerType.java branches/newstyle-java-types/src/org/python/antlr/ast/exprType.java branches/newstyle-java-types/src/org/python/antlr/ast/keywordType.java branches/newstyle-java-types/src/org/python/antlr/ast/modType.java branches/newstyle-java-types/src/org/python/antlr/ast/sliceType.java branches/newstyle-java-types/src/org/python/antlr/ast/stmtType.java branches/newstyle-java-types/src/org/python/antlr/base/excepthandler.java branches/newstyle-java-types/src/org/python/antlr/base/expr.java branches/newstyle-java-types/src/org/python/antlr/base/mod.java branches/newstyle-java-types/src/org/python/antlr/base/slice.java branches/newstyle-java-types/src/org/python/antlr/base/stmt.java branches/newstyle-java-types/src/org/python/antlr/op/Add.java branches/newstyle-java-types/src/org/python/antlr/op/AddDerived.java branches/newstyle-java-types/src/org/python/antlr/op/And.java branches/newstyle-java-types/src/org/python/antlr/op/AndDerived.java branches/newstyle-java-types/src/org/python/antlr/op/AugLoad.java branches/newstyle-java-types/src/org/python/antlr/op/AugLoadDerived.java branches/newstyle-java-types/src/org/python/antlr/op/AugStore.java branches/newstyle-java-types/src/org/python/antlr/op/AugStoreDerived.java branches/newstyle-java-types/src/org/python/antlr/op/BitAnd.java branches/newstyle-java-types/src/org/python/antlr/op/BitAndDerived.java branches/newstyle-java-types/src/org/python/antlr/op/BitOr.java branches/newstyle-java-types/src/org/python/antlr/op/BitOrDerived.java branches/newstyle-java-types/src/org/python/antlr/op/BitXor.java branches/newstyle-java-types/src/org/python/antlr/op/BitXorDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Del.java branches/newstyle-java-types/src/org/python/antlr/op/DelDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Div.java branches/newstyle-java-types/src/org/python/antlr/op/DivDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Eq.java branches/newstyle-java-types/src/org/python/antlr/op/EqDerived.java branches/newstyle-java-types/src/org/python/antlr/op/FloorDiv.java branches/newstyle-java-types/src/org/python/antlr/op/FloorDivDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Gt.java branches/newstyle-java-types/src/org/python/antlr/op/GtDerived.java branches/newstyle-java-types/src/org/python/antlr/op/GtE.java branches/newstyle-java-types/src/org/python/antlr/op/GtEDerived.java branches/newstyle-java-types/src/org/python/antlr/op/In.java branches/newstyle-java-types/src/org/python/antlr/op/InDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Invert.java branches/newstyle-java-types/src/org/python/antlr/op/InvertDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Is.java branches/newstyle-java-types/src/org/python/antlr/op/IsDerived.java branches/newstyle-java-types/src/org/python/antlr/op/IsNot.java branches/newstyle-java-types/src/org/python/antlr/op/IsNotDerived.java branches/newstyle-java-types/src/org/python/antlr/op/LShift.java branches/newstyle-java-types/src/org/python/antlr/op/LShiftDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Load.java branches/newstyle-java-types/src/org/python/antlr/op/LoadDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Lt.java branches/newstyle-java-types/src/org/python/antlr/op/LtDerived.java branches/newstyle-java-types/src/org/python/antlr/op/LtE.java branches/newstyle-java-types/src/org/python/antlr/op/LtEDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Mod.java branches/newstyle-java-types/src/org/python/antlr/op/ModDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Mult.java branches/newstyle-java-types/src/org/python/antlr/op/MultDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Not.java branches/newstyle-java-types/src/org/python/antlr/op/NotDerived.java branches/newstyle-java-types/src/org/python/antlr/op/NotEq.java branches/newstyle-java-types/src/org/python/antlr/op/NotEqDerived.java branches/newstyle-java-types/src/org/python/antlr/op/NotIn.java branches/newstyle-java-types/src/org/python/antlr/op/NotInDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Or.java branches/newstyle-java-types/src/org/python/antlr/op/OrDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Param.java branches/newstyle-java-types/src/org/python/antlr/op/ParamDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Pow.java branches/newstyle-java-types/src/org/python/antlr/op/PowDerived.java branches/newstyle-java-types/src/org/python/antlr/op/RShift.java branches/newstyle-java-types/src/org/python/antlr/op/RShiftDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Store.java branches/newstyle-java-types/src/org/python/antlr/op/StoreDerived.java branches/newstyle-java-types/src/org/python/antlr/op/Sub.java branches/newstyle-java-types/src/org/python/antlr/op/SubDerived.java branches/newstyle-java-types/src/org/python/antlr/op/UAdd.java branches/newstyle-java-types/src/org/python/antlr/op/UAddDerived.java branches/newstyle-java-types/src/org/python/antlr/op/USub.java branches/newstyle-java-types/src/org/python/antlr/op/USubDerived.java Property Changed: ---------------- branches/newstyle-java-types/ branches/newstyle-java-types/ast/ branches/newstyle-java-types/src/org/python/antlr/ branches/newstyle-java-types/src/org/python/antlr/ast/ branches/newstyle-java-types/src/org/python/compiler/ Property changes on: branches/newstyle-java-types ___________________________________________________________________ Modified: svnmerge-integrated - /branches/nowalker:1-5263 /trunk/jython:1-5664 + /branches/nowalker:1-5263 /trunk/jython:1-5729 /branches/astwrite:1-5692 Modified: svn:mergeinfo - /trunk/jython:5565-5661 + /trunk/jython:5565-5661,5670-5726 Modified: branches/newstyle-java-types/CoreExposed.includes =================================================================== --- branches/newstyle-java-types/CoreExposed.includes 2008-12-10 08:10:31 UTC (rev 5731) +++ branches/newstyle-java-types/CoreExposed.includes 2008-12-10 08:23:53 UTC (rev 5732) @@ -1,3 +1,4 @@ +org/python/core/AstList.class org/python/core/PyArray.class org/python/core/PyBaseString.class org/python/core/PyBaseException.class @@ -55,3 +56,98 @@ org/python/modules/zipimport/zipimporter.class org/python/modules/PyStruct.class org/python/modules/PyTeeIterator.class +org/python/antlr/AST.class +org/python/antlr/ast/alias.class +org/python/antlr/ast/arguments.class +org/python/antlr/ast/Assert.class +org/python/antlr/ast/Assign.class +org/python/antlr/ast/Attribute.class +org/python/antlr/ast/AugAssign.class +org/python/antlr/ast/BinOp.class +org/python/antlr/ast/BoolOp.class +org/python/antlr/ast/Break.class +org/python/antlr/ast/Call.class +org/python/antlr/ast/ClassDef.class +org/python/antlr/ast/Compare.class +org/python/antlr/ast/comprehension.class +org/python/antlr/ast/Continue.class +org/python/antlr/ast/Delete.class +org/python/antlr/ast/Dict.class +org/python/antlr/ast/Ellipsis.class +org/python/antlr/ast/ExceptHandler.class +org/python/antlr/ast/Exec.class +org/python/antlr/ast/Expr.class +org/python/antlr/ast/Expression.class +org/python/antlr/ast/ExtSlice.class +org/python/antlr/ast/For.class +org/python/antlr/ast/FunctionDef.class +org/python/antlr/ast/GeneratorExp.class +org/python/antlr/ast/Global.class +org/python/antlr/ast/If.class +org/python/antlr/ast/IfExp.class +org/python/antlr/ast/Import.class +org/python/antlr/ast/ImportFrom.class +org/python/antlr/ast/Index.class +org/python/antlr/ast/Interactive.class +org/python/antlr/ast/keyword.class +org/python/antlr/ast/Lambda.class +org/python/antlr/ast/List.class +org/python/antlr/ast/ListComp.class +org/python/antlr/ast/Module.class +org/python/antlr/ast/Name.class +org/python/antlr/ast/Num.class +org/python/antlr/ast/Pass.class +org/python/antlr/ast/Print.class +org/python/antlr/ast/Raise.class +org/python/antlr/ast/Repr.class +org/python/antlr/ast/Return.class +org/python/antlr/ast/Slice.class +org/python/antlr/ast/Str.class +org/python/antlr/ast/Subscript.class +org/python/antlr/ast/Suite.class +org/python/antlr/ast/TryExcept.class +org/python/antlr/ast/TryFinally.class +org/python/antlr/ast/Tuple.class +org/python/antlr/ast/UnaryOp.class +org/python/antlr/ast/While.class +org/python/antlr/ast/With.class +org/python/antlr/ast/Yield.class +org/python/antlr/base/excepthandler.class +org/python/antlr/base/expr.class +org/python/antlr/base/mod.class +org/python/antlr/base/slice.class +org/python/antlr/base/stmt.class +org/python/antlr/op/Add.class +org/python/antlr/op/And.class +org/python/antlr/op/AugLoad.class +org/python/antlr/op/AugStore.class +org/python/antlr/op/BitAnd.class +org/python/antlr/op/BitOr.class +org/python/antlr/op/BitXor.class +org/python/antlr/op/Del.class +org/python/antlr/op/Div.class +org/python/antlr/op/Eq.class +org/python/antlr/op/FloorDiv.class +org/python/antlr/op/Gt.class +org/python/antlr/op/GtE.class +org/python/antlr/op/In.class +org/python/antlr/op/Invert.class +org/python/antlr/op/Is.class +org/python/antlr/op/IsNot.class +org/python/antlr/op/Load.class +org/python/antlr/op/LShift.class +org/python/antlr/op/Lt.class +org/python/antlr/op/LtE.class +org/python/antlr/op/Mod.class +org/python/antlr/op/Mult.class +org/python/antlr/op/Not.class +org/python/antlr/op/NotEq.class +org/python/antlr/op/NotIn.class +org/python/antlr/op/Or.class +org/python/antlr/op/Param.class +org/python/antlr/op/Pow.class +org/python/antlr/op/RShift.class +org/python/antlr/op/Store.class +org/python/antlr/op/Sub.class +org/python/antlr/op/UAdd.class +org/python/antlr/op/USub.class Deleted: branches/newstyle-java-types/Lib/_ast.py =================================================================== --- branches/newstyle-java-types/Lib/_ast.py 2008-12-10 08:10:31 UTC (rev 5731) +++ branches/newstyle-java-types/Lib/_ast.py 2008-12-10 08:23:53 UTC (rev 5732) @@ -1,79 +0,0 @@ -from org.python.antlr.ast.boolopType import And,Or -from org.python.antlr.ast.operatorType import Add,Sub,Mult,Div,FloorDiv,Mod,LShift,RShift,BitOr,BitAnd,BitXor,Pow -from org.python.antlr.ast.cmpopType import Eq,Gt,GtE,In,Is,IsNot,Lt,LtE,NotEq,NotIn -from org.python.antlr.ast.unaryopType import Invert,Not,UAdd,USub -from org.python.core.PyTableCode import PyCF_ONLY_AST -from org.python.antlr.ast.expr_contextType import Load, Store, Del, AugLoad, AugStore, Param - -from org.python.antlr import AST - -from org.python.antlr.ast import Assert -from org.python.antlr.ast import Assign -from org.python.antlr.ast import Attribute -from org.python.antlr.ast import AugAssign -from org.python.antlr.ast import BinOp -from org.python.antlr.ast import BoolOp -from org.python.antlr.ast import Break -from org.python.antlr.ast import Call -from org.python.antlr.ast import ClassDef -from org.python.antlr.ast import Compare -from org.python.antlr.ast import Continue -from org.python.antlr.ast import Delete -from org.python.antlr.ast import Dict -from org.python.antlr.ast import Ellipsis -from org.python.antlr.ast import Exec -from org.python.antlr.ast import Expr -from org.python.antlr.ast import Expression -from org.python.antlr.ast import ExtSlice -from org.python.antlr.ast import For -from org.python.antlr.ast import FunctionDef -from org.python.antlr.ast import GeneratorExp -from org.python.antlr.ast import Global -from org.python.antlr.ast import If -from org.python.antlr.ast import IfExp -from org.python.antlr.ast import Import -from org.python.antlr.ast import ImportFrom -from org.python.antlr.ast import Index -from org.python.antlr.ast import Interactive -from org.python.antlr.ast import Lambda -from org.python.antlr.ast import List -from org.python.antlr.ast import ListComp -from org.python.antlr.ast import Module -from org.python.antlr.ast import Name -from org.python.antlr.ast import Num -from org.python.antlr.ast import Pass -from org.python.antlr.ast import Print -from org.python.antlr.ast import Raise -from org.python.antlr.ast import Repr -from org.python.antlr.ast import Return -from org.python.antlr.ast import Slice -from org.python.antlr.ast import Str -from org.python.antlr.ast import Subscript -from org.python.antlr.ast import Suite -from org.python.antlr.ast import TryExcept -from org.python.antlr.ast import TryFinally -from org.python.antlr.ast import Tuple -from org.python.antlr.ast import UnaryOp -#from org.python.antlr.ast import Unicode -from org.python.antlr.ast import While -from org.python.antlr.ast import With -from org.python.antlr.ast import Yield - -import org.python.antlr.ast.aliasType as alias -import org.python.antlr.ast.argumentsType as arguments -import org.python.antlr.ast.boolopType as boolop -import org.python.antlr.ast.cmpopType as cmpop -import org.python.antlr.ast.comprehensionType as comprehension -import org.python.antlr.ast.excepthandlerType as excepthandler -import org.python.antlr.ast.exprType as expr -import org.python.antlr.ast.expr_contextType as expr_context -import org.python.antlr.ast.keywordType as keyword -import org.python.antlr.ast.modType as mod -import org.python.antlr.ast.operatorType as operator -import org.python.antlr.ast.sliceType as slice -import org.python.antlr.ast.stmtType as stmt -import org.python.antlr.ast.unaryopType as unaryop - -#Set to the same value as the CPython version we are targetting. -#note that this number comes from the revision number in CPython's repository. -__version__ = 43614 Modified: branches/newstyle-java-types/Lib/ast.py =================================================================== --- branches/newstyle-java-types/Lib/ast.py 2008-12-10 08:10:31 UTC (rev 5731) +++ branches/newstyle-java-types/Lib/ast.py 2008-12-10 08:23:53 UTC (rev 5732) @@ -25,35 +25,10 @@ :copyright: Copyright 2008 by Armin Ronacher. :license: Python License. """ -import sys from _ast import * from _ast import __version__ -if sys.platform.startswith('java'): - import array - ast_list = array.ArrayType - - def get_class_name(t): - result = t.__class__.__name__ - if result in ("expr_contextType", - "boolopType", - "unaryopType", - "cmpopType", - "operatorType"): - result = str(t) - if result == "AugLoad": - result = "Load" - elif result == "AugStore": - result = "Store" - elif result.endswith("Type"): - result = result[:-4] - return result -else: - ast_list = list - get_class_name = lambda node: node.__class__.__name__ - - def parse(expr, filename='<unknown>', mode='exec'): """ Parse an expression into an AST node. @@ -105,7 +80,7 @@ def _format(node): if isinstance(node, AST): fields = [(a, _format(b)) for a, b in iter_fields(node)] - rv = '%s(%s' % (get_class_name(node), ', '.join( + rv = '%s(%s' % (node.__class__.__name__, ', '.join( ('%s=%s' % field for field in fields) if annotate_fields else (b for a, b in fields) @@ -115,11 +90,11 @@ rv += ', '.join('%s=%s' % (a, _format(getattr(node, a))) for a in node._attributes) return rv + ')' - elif isinstance(node, ast_list): + elif isinstance(node, list): return '[%s]' % ', '.join(_format(x) for x in node) return repr(node) if not isinstance(node, AST): - raise TypeError('expected AST, got %r' % get_class_name(node)) + raise TypeError('expected AST, got %r' % node.__class__.__name__) return _format(node) @@ -193,7 +168,7 @@ for name, field in iter_fields(node): if isinstance(field, AST): yield field - elif isinstance(field, ast_list): + elif isinstance(field, list): for item in field: if isinstance(item, AST): yield item @@ -206,7 +181,7 @@ will be raised. """ if not isinstance(node, (FunctionDef, ClassDef, Module)): - raise TypeError("%r can't have docstrings" % get_class_name(node)) + raise TypeError("%r can't have docstrings" % node.__class__.__name__) if node.body and isinstance(node.body[0], Expr) and \ isinstance(node.body[0].value, Str): if clean: @@ -251,14 +226,14 @@ def visit(self, node): """Visit a node.""" - method = 'visit_' + get_class_name(node) + method = 'visit_' + node.__class__.__name__ visitor = getattr(self, method, self.generic_visit) return visitor(node) def generic_visit(self, node): """Called if no explicit visitor function exists for a node.""" for field, value in iter_fields(node): - if isinstance(value, ast_list): + if isinstance(value, list): for item in value: if isinstance(item, AST): self.visit(item) @@ -305,7 +280,7 @@ def generic_visit(self, node): for field, old_value in iter_fields(node): old_value = getattr(node, field, None) - if isinstance(old_value, ast_list): + if isinstance(old_value, list): new_values = [] for value in old_value: if isinstance(value, AST): Modified: branches/newstyle-java-types/Lib/inspect.py =================================================================== --- branches/newstyle-java-types/Lib/inspect.py 2008-12-10 08:10:31 UTC (rev 5731) +++ branches/newstyle-java-types/Lib/inspect.py 2008-12-10 08:23:53 UTC (rev 5732) @@ -315,6 +315,13 @@ return None if not isinstance(doc, types.StringTypes): return None + return cleandoc(doc) + +def cleandoc(doc): + """Clean up indentation from docstrings. + + Any whitespace that can be uniformly removed from the second line + onwards is removed.""" try: lines = string.split(string.expandtabs(doc), '\n') except UnicodeError: Modified: branches/newstyle-java-types/Lib/test/test_ast.py =================================================================== --- branches/newstyle-java-types/Lib/test/test_ast.py 2008-12-10 08:10:31 UTC (rev 5731) +++ branches/newstyle-java-types/Lib/test/test_ast.py 2008-12-10 08:23:53 UTC (rev 5732) @@ -1,36 +1,22 @@ -#Taken and modified from CPython's release25-maint branch, revision 62446. -import sys,os, itertools +import sys, itertools, unittest +from test import test_support import ast -def get_class_name(t): - result = t.__class__.__name__ - if os.name.startswith('java'): - if result in ("expr_contextType", - "boolopType", - "unaryopType", - "cmpopType", - "operatorType"): - result = t.name() - else: - result = result.split(".")[-1] - if result.endswith("Type"): - result = result[:-4] - return result - def to_tuple(t): if t is None or isinstance(t, (basestring, int, long, complex)): return t - elif hasattr(t, '__iter__'): + elif isinstance(t, list): return [to_tuple(e) for e in t] - result = [get_class_name(t)] + result = [t.__class__.__name__] if hasattr(t, 'lineno') and hasattr(t, 'col_offset'): result.append((t.lineno, t.col_offset)) - if not hasattr(t, '_fields') or t._fields is None: + if t._fields is None: return tuple(result) for f in t._fields: result.append(to_tuple(getattr(t, f))) return tuple(result) + # These tests are compiled through "exec" # There should be atleast one test per statement exec_tests = [ @@ -134,49 +120,192 @@ # TODO: expr_context, slice, boolop, operator, unaryop, cmpop, comprehension # excepthandler, arguments, keywords, alias -if __name__=='__main__' and sys.argv[1:] == ['-g']: - for statements, kind in ((exec_tests, "exec"), (single_tests, "single"), - (eval_tests, "eval")): - print kind+"_results = [" - for s in statements: - print repr(to_tuple(compile(s, "?", kind, 0x400)))+"," - print "]" - print "run_tests()" - raise SystemExit +class AST_Tests(unittest.TestCase): -def test_order(ast_node, parent_pos): - - if (not isinstance(ast_node, ast.AST) - or not hasattr(ast_node, '_fields') - or ast_node._fields == None): + def _assert_order(self, ast_node, parent_pos): + if not isinstance(ast_node, ast.AST) or ast_node._fields is None: return - if isinstance(ast_node, (ast.expr, ast.stmt, ast.excepthandler)): - node_pos = (ast_node.lineno, ast_node.col_offset) - assert node_pos >= parent_pos, (node_pos, parent_pos) - parent_pos = (ast_node.lineno, ast_node.col_offset) - for name in ast_node._fields: - value = getattr(ast_node, name) - if hasattr(value, '__iter__'): - for child in value: - test_order(child, parent_pos) - elif value != None: - test_order(value, parent_pos) + if isinstance(ast_node, (ast.expr, ast.stmt, ast.excepthandler)): + node_pos = (ast_node.lineno, ast_node.col_offset) + self.assert_(node_pos >= parent_pos) + parent_pos = (ast_node.lineno, ast_node.col_offset) + for name in ast_node._fields: + value = getattr(ast_node, name) + if isinstance(value, list): + for child in value: + self._assert_order(child, parent_pos) + elif value is not None: + self._assert_order(value, parent_pos) -def run_tests(): - for input, output, kind in ((exec_tests, exec_results, "exec"), - (single_tests, single_results, "single"), - (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, "expected %s, got %s" % ( - o, to_tuple(ast_tree)) - test_order(ast_tree, (0, 0)) + def test_snippets(self): + for input, output, kind in ((exec_tests, exec_results, "exec"), + (single_tests, single_results, "single"), + (eval_tests, eval_results, "eval")): + for i, o in itertools.izip(input, output): + ast_tree = compile(i, "?", kind, ast.PyCF_ONLY_AST) + self.assertEquals(to_tuple(ast_tree), o) + self._assert_order(ast_tree, (0, 0)) -# XXX: AugStore added for Jython. Short term it is too hard to emit just "Store" as CPython does. + def test_nodeclasses(self): + x = ast.BinOp(1, 2, 3, lineno=0) + self.assertEquals(x.left.n, 1) + self.assertEquals(int(x.op), 2) + self.assertEquals(x.right.n, 3) + self.assertEquals(x.lineno, 0) + + # node raises exception when not given enough arguments + self.assertRaises(TypeError, ast.BinOp, 1, 2) + + # can set attributes through kwargs too + x = ast.BinOp(left=1, op=2, right=3, lineno=0) + self.assertEquals(x.left.n, 1) + self.assertEquals(int(x.op), 2) + self.assertEquals(x.right.n, 3) + self.assertEquals(x.lineno, 0) + + # this used to fail because Sub._fields was None + x = ast.Sub() + + def test_pickling(self): + import pickle + mods = [pickle] + try: + import cPickle + mods.append(cPickle) + except ImportError: + pass + protocols = [0, 1, 2] + for mod in mods: + for protocol in protocols: + for ast in (compile(i, "?", "exec", 0x400) for i in exec_tests): + ast2 = mod.loads(mod.dumps(ast, protocol)) + self.assertEquals(to_tuple(ast2), to_tuple(ast)) + + +class ASTHelpers_Test(unittest.TestCase): + + def test_parse(self): + a = ast.parse('foo(1 + 1)') + b = compile('foo(1 + 1)', '<unknown>', 'exec', ast.PyCF_ONLY_AST) + self.assertEqual(ast.dump(a), ast.dump(b)) + + def test_dump(self): + node = ast.parse('spam(eggs, "and cheese")') + self.assertEqual(ast.dump(node), + "Module(body=[Expr(value=Call(func=Name(id='spam', ctx=Load()), " + "args=[Name(id='eggs', ctx=Load()), Str(s='and cheese')], " + "keywords=[], starargs=None, kwargs=None))])" + ) + self.assertEqual(ast.dump(node, annotate_fields=False), + "Module([Expr(Call(Name('spam', Load()), [Name('eggs', Load()), " + "Str('and cheese')], [], None, None))])" + ) + self.assertEqual(ast.dump(node, include_attributes=True), + "Module(body=[Expr(value=Call(func=Name(id='spam', ctx=Load(), " + "lineno=1, col_offset=0), args=[Name(id='eggs', ctx=Load(), " + "lineno=1, col_offset=5), Str(s='and cheese', lineno=1, " + "col_offset=11)], keywords=[], starargs=None, kwargs=None, " + "lineno=1, col_offset=0), lineno=1, col_offset=0)])" + ) + + def test_copy_location(self): + src = ast.parse('1 + 1', mode='eval') + src.body.right = ast.copy_location(ast.Num(2), src.body.right) + self.assertEqual(ast.dump(src, include_attributes=True), + 'Expression(body=BinOp(left=Num(n=1, lineno=1, col_offset=0), ' + 'op=Add(), right=Num(n=2, lineno=1, col_offset=4), lineno=1, ' + 'col_offset=0))' + ) + + def test_fix_missing_locations(self): + src = ast.parse('write("spam")') + src.body.append(ast.Expr(ast.Call(ast.Name('spam', ast.Load()), + [ast.Str('eggs')], [], None, None))) + self.assertEqual(src, ast.fix_missing_locations(src)) + self.assertEqual(ast.dump(src, include_attributes=True), + "Module(body=[Expr(value=Call(func=Name(id='write', ctx=Load(), " + "lineno=1, col_offset=0), args=[Str(s='spam', lineno=1, " + "col_offset=6)], keywords=[], starargs=None, kwargs=None, " + "lineno=1, col_offset=0), lineno=1, col_offset=0), " + "Expr(value=Call(func=Name(id='spam', ctx=Load(), lineno=1, " + "col_offset=0), args=[Str(s='eggs', lineno=1, col_offset=0)], " + "keywords=[], starargs=None, kwargs=None, lineno=1, " + "col_offset=0), lineno=1, col_offset=0)])" + ) + + def test_increment_lineno(self): + src = ast.parse('1 + 1', mode='eval') + self.assertEqual(ast.increment_lineno(src, n=3), src) + self.assertEqual(ast.dump(src, include_attributes=True), + 'Expression(body=BinOp(left=Num(n=1, lineno=4, col_offset=0), ' + 'op=Add(), right=Num(n=1, lineno=4, col_offset=4), lineno=4, ' + 'col_offset=0))' + ) + + def test_iter_fields(self): + node = ast.parse('foo()', mode='eval') + d = dict(ast.iter_fields(node.body)) + self.assertEqual(d.pop('func').id, 'foo') + + #XXX: tests for equality between astlist and regular lists not + # working, breaking this test up into its components. + #self.assertEqual(d, {'keywords': [], 'kwargs': None, + # 'args': [], 'starargs': None}) + assert len(d) == 4 + assert d['keywords'] is not None + assert len(d['keywords']) == 0 + assert d['args'] is not None + assert len(d['args']) == 0 + assert d['kwargs'] is None + assert d['starargs'] is None + + def test_iter_child_nodes(self): + node = ast.parse("spam(23, 42, eggs='leek')", mode='eval') + self.assertEqual(len(list(ast.iter_child_nodes(node.body))), 4) + iterator = ast.iter_child_nodes(node.body) + self.assertEqual(iterator.next().id, 'spam') + self.assertEqual(iterator.next().n, 23) + self.assertEqual(iterator.next().n, 42) + self.assertEqual(ast.dump(iterator.next()), + "keyword(arg='eggs', value=Str(s='leek'))" + ) + + def test_get_docstring(self): + node = ast.parse('def foo():\n """line one\n line two"""') + self.assertEqual(ast.get_docstring(node.body[0]), + 'line one\nline two') + + def test_literal_eval(self): + self.assertEqual(ast.literal_eval(... [truncated message content] |
From: <pj...@us...> - 2008-12-10 08:10:32
|
Revision: 5731 http://jython.svn.sourceforge.net/jython/?rev=5731&view=rev Author: pjenvey Date: 2008-12-10 08:10:31 +0000 (Wed, 10 Dec 2008) Log Message: ----------- merge in new test from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_with.py -c 67684 Modified Paths: -------------- trunk/jython/Lib/test/test_with.py Modified: trunk/jython/Lib/test/test_with.py =================================================================== --- trunk/jython/Lib/test/test_with.py 2008-12-10 07:34:57 UTC (rev 5730) +++ trunk/jython/Lib/test/test_with.py 2008-12-10 08:10:31 UTC (rev 5731) @@ -505,7 +505,37 @@ self.assertRaises(GeneratorExit, shouldThrow) + def testErrorsInBool(self): + # issue4589: __exit__ return code may raise an exception + # when looking at its truth value. + class cm(object): + def __init__(self, bool_conversion): + class Bool: + def __nonzero__(self): + return bool_conversion() + self.exit_result = Bool() + def __enter__(self): + return 3 + def __exit__(self, a, b, c): + return self.exit_result + + def trueAsBool(): + with cm(lambda: True): + self.fail("Should NOT see this") + trueAsBool() + + def falseAsBool(): + with cm(lambda: False): + self.fail("Should raise") + self.assertRaises(AssertionError, falseAsBool) + + def failAsBool(): + with cm(lambda: 1//0): + self.fail("Should NOT see this") + self.assertRaises(ZeroDivisionError, failAsBool) + + class NonLocalFlowControlTestCase(unittest.TestCase, ContextmanagerAssertionMixin): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-12-10 07:35:01
|
Revision: 5730 http://jython.svn.sourceforge.net/jython/?rev=5730&view=rev Author: pjenvey Date: 2008-12-10 07:34:57 +0000 (Wed, 10 Dec 2008) Log Message: ----------- hide posixy stuff when not on posix Modified Paths: -------------- trunk/jython/Lib/os.py Modified: trunk/jython/Lib/os.py =================================================================== --- trunk/jython/Lib/os.py 2008-12-10 07:09:49 UTC (rev 5729) +++ trunk/jython/Lib/os.py 2008-12-10 07:34:57 UTC (rev 5730) @@ -494,6 +494,9 @@ except: raise f = File(sys.getPath(path)) + # XXX: jna-posix implements similar link detection in + # JavaFileStat.calculateSymlink, fallback to that instead when not + # native abs_parent = f.getAbsoluteFile().getParentFile() if not abs_parent: # root isn't a link @@ -669,29 +672,6 @@ except: raise OSError(errno.EBADF, strerror(errno.EBADF)) -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)) - - def symlink(src, dst): - """symlink(src, dst) - - Create a symbolic link pointing to src named dst. - """ - _posix.symlink(src, sys.getPath(dst)) - - def readlink(path): - """readlink(path) -> path - - Return a string representing the path to which the symbolic link - points. - """ - return _posix.readlink(sys.getPath(path)) - # Provide lazy popen*, and system objects # Do these lazily, as most jython programs don't need them, # and they are very expensive to initialize @@ -906,66 +886,89 @@ The optional second argument can specify an alternate default.""" return environ.get(key, default) -def getegid(): - """getegid() -> egid +if _name == 'posix': + def link(src, dst): + """link(src, dst) - Return the current process's effective group id.""" - return _posix.getegid() + Create a hard link to a file. + """ + _posix.link(sys.getPath(src), sys.getPath(dst)) -def geteuid(): - """geteuid() -> euid + def symlink(src, dst): + """symlink(src, dst) - Return the current process's effective user id.""" - return _posix.geteuid() + Create a symbolic link pointing to src named dst. + """ + _posix.symlink(src, sys.getPath(dst)) -def getgid(): - """getgid() -> gid + def readlink(path): + """readlink(path) -> path - Return the current process's group id.""" - return _posix.getgid() + Return a string representing the path to which the symbolic link + points. + """ + return _posix.readlink(sys.getPath(path)) -def getlogin(): - """getlogin() -> string + def getegid(): + """getegid() -> egid - Return the actual login name.""" - return _posix.getlogin() + Return the current process's effective group id.""" + return _posix.getegid() -def getpgrp(): - """getpgrp() -> pgrp + def geteuid(): + """geteuid() -> euid - Return the current process group id.""" - return _posix.getpgrp() + Return the current process's effective user id.""" + return _posix.geteuid() -def getpid(): - """getpid() -> pid + def getgid(): + """getgid() -> gid - Return the current process id.""" - return _posix.getpid() + Return the current process's group id.""" + return _posix.getgid() -def getppid(): - """getppid() -> ppid + def getlogin(): + """getlogin() -> string - Return the parent's process id.""" - return _posix.getppid() + Return the actual login name.""" + return _posix.getlogin() -def getuid(): - """getuid() -> uid + def getpgrp(): + """getpgrp() -> pgrp - Return the current process's user id.""" - return _posix.getuid() + Return the current process group id.""" + return _posix.getpgrp() -def setpgrp(): - """setpgrp() + def getppid(): + """getppid() -> ppid - Make this process a session leader.""" - return _posix.setpgrp() + Return the parent's process id.""" + return _posix.getppid() -def setsid(): - """setsid() + def getuid(): + """getuid() -> uid - Call the system call setsid().""" - return _posix.setsid() + Return the current process's user id.""" + return _posix.getuid() + def setpgrp(): + """setpgrp() + + Make this process a session leader.""" + return _posix.setpgrp() + + def setsid(): + """setsid() + + Call the system call setsid().""" + return _posix.setsid() + +def getpid(): + """getpid() -> pid + + Return the current process id.""" + return _posix.getpid() + def isatty(fileno): """isatty(fd) -> bool This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-10 07:09:53
|
Revision: 5729 http://jython.svn.sourceforge.net/jython/?rev=5729&view=rev Author: cgroves Date: 2008-12-10 07:09:49 +0000 (Wed, 10 Dec 2008) Log Message: ----------- Allow setattr and delattr to access the dicts of PyJavaTypes. Fixes test_strptime as Time was expected to allow modification to its dict. Modified Paths: -------------- branches/newstyle-java-types/src/org/python/core/PyJavaType.java branches/newstyle-java-types/src/org/python/core/PyType.java Modified: branches/newstyle-java-types/src/org/python/core/PyJavaType.java =================================================================== --- branches/newstyle-java-types/src/org/python/core/PyJavaType.java 2008-12-10 06:47:19 UTC (rev 5728) +++ branches/newstyle-java-types/src/org/python/core/PyJavaType.java 2008-12-10 07:09:49 UTC (rev 5729) @@ -40,7 +40,15 @@ return PyObject.class.isAssignableFrom(underlying_class) ? null : underlying_class; } + // Java types are ok with things being added and removed from their dicts as long as there isn't + // something there, so let these checks through @Override + protected void checkDelattr() {} + + @Override + protected void checkSetattr() {} + + @Override protected void init() { name = underlying_class.getName(); // Strip the java fully qualified class name from Py classes in core Modified: branches/newstyle-java-types/src/org/python/core/PyType.java =================================================================== --- branches/newstyle-java-types/src/org/python/core/PyType.java 2008-12-10 06:47:19 UTC (rev 5728) +++ branches/newstyle-java-types/src/org/python/core/PyType.java 2008-12-10 07:09:49 UTC (rev 5729) @@ -1076,11 +1076,15 @@ type___setattr__(name, value); } - final void type___setattr__(String name, PyObject value) { + protected void checkSetattr() { if (builtin) { throw Py.TypeError(String.format("can't set attributes of built-in/extension type " - + "'%s'", this.name)); + + "'%s'", this.name)); } + } + + final void type___setattr__(String name, PyObject value) { + checkSetattr(); super.__setattr__(name, value); if (name == "__set__") { if (!has_set && lookup("__set__") != null) { @@ -1114,11 +1118,15 @@ type___delattr__(asName(name)); } - final void type___delattr__(String name) { + protected void checkDelattr() { if (builtin) { throw Py.TypeError(String.format("can't set attributes of built-in/extension type " - + "'%s'", this.name)); + + "'%s'", this.name)); } + } + + final void type___delattr__(String name) { + checkDelattr(); super.__delattr__(name); if (name == "__set__") { if (has_set && lookup("__set__") == null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-10 06:47:23
|
Revision: 5728 http://jython.svn.sourceforge.net/jython/?rev=5728&view=rev Author: cgroves Date: 2008-12-10 06:47:19 +0000 (Wed, 10 Dec 2008) Log Message: ----------- Like exceptions, operator needs to extend PyObject to keep from picking up Object methods. Fixes test_richcmp. Modified Paths: -------------- branches/newstyle-java-types/src/org/python/modules/math.java branches/newstyle-java-types/src/org/python/modules/operator.java Modified: branches/newstyle-java-types/src/org/python/modules/math.java =================================================================== --- branches/newstyle-java-types/src/org/python/modules/math.java 2008-12-10 06:30:28 UTC (rev 5727) +++ branches/newstyle-java-types/src/org/python/modules/math.java 2008-12-10 06:47:19 UTC (rev 5728) @@ -1,8 +1,13 @@ // Copyright (c) Corporation for National Research Initiatives package org.python.modules; -import org.python.core.*; -import java.lang.Math; +import org.python.core.ClassDictInit; +import org.python.core.Py; +import org.python.core.PyFloat; +import org.python.core.PyInteger; +import org.python.core.PyLong; +import org.python.core.PyObject; +import org.python.core.PyTuple; public class math implements ClassDictInit { public static PyFloat pi = new PyFloat(Math.PI); @@ -74,7 +79,7 @@ private static double calculateLongLog(PyLong v) { int e[] = new int[1]; - double x = ((PyLong)v).scaledDoubleValue(e); + double x = v.scaledDoubleValue(e); if (x <= 0.0) throw Py.ValueError("math domain error"); return log(x) + (e[0]*8.0)*log(2.0); } Modified: branches/newstyle-java-types/src/org/python/modules/operator.java =================================================================== --- branches/newstyle-java-types/src/org/python/modules/operator.java 2008-12-10 06:30:28 UTC (rev 5727) +++ branches/newstyle-java-types/src/org/python/modules/operator.java 2008-12-10 06:47:19 UTC (rev 5728) @@ -1,8 +1,17 @@ // Copyright (c) Corporation for National Research Initiatives package org.python.modules; -import org.python.core.*; -import org.python.expose.ExposedGet; +import org.python.core.ArgParser; +import org.python.core.ClassDictInit; +import org.python.core.Py; +import org.python.core.PyBuiltinFunctionSet; +import org.python.core.PyIgnoreMethodTag; +import org.python.core.PyNewWrapper; +import org.python.core.PyObject; +import org.python.core.PyString; +import org.python.core.PyTuple; +import org.python.core.PyType; +import org.python.core.PyUnicode; import org.python.expose.ExposedMethod; import org.python.expose.ExposedNew; import org.python.expose.ExposedType; @@ -106,7 +115,7 @@ } } -public class operator implements ClassDictInit +public class operator extends PyObject implements ClassDictInit { public static PyString __doc__ = new PyString( "Operator interface.\n"+ @@ -119,33 +128,28 @@ "are those\n"+ "used for special class methods; variants without leading "+ "and trailing\n"+ - "'__' are also provided for convenience.\n" - ); + "'__' are also provided for convenience.\n"); public static void classDictInit(PyObject dict) throws PyIgnoreMethodTag { dict.__setitem__("__add__", new OperatorFunctions("__add__", 0, 2)); dict.__setitem__("add", new OperatorFunctions("add", 0, 2)); - dict.__setitem__("__concat__", - new OperatorFunctions("__concat__", 0, 2)); + dict.__setitem__("__concat__", new OperatorFunctions("__concat__", 0, 2)); dict.__setitem__("concat", new OperatorFunctions("concat", 0, 2)); dict.__setitem__("__and__", new OperatorFunctions("__and__", 1, 2)); dict.__setitem__("and_", new OperatorFunctions("and_", 1, 2)); dict.__setitem__("__div__", new OperatorFunctions("__div__", 2, 2)); dict.__setitem__("div", new OperatorFunctions("div", 2, 2)); - dict.__setitem__("__lshift__", - new OperatorFunctions("__lshift__", 3, 2)); + dict.__setitem__("__lshift__", new OperatorFunctions("__lshift__", 3, 2)); dict.__setitem__("lshift", new OperatorFunctions("lshift", 3, 2)); dict.__setitem__("__mod__", new OperatorFunctions("__mod__", 4, 2)); dict.__setitem__("mod", new OperatorFunctions("mod", 4, 2)); dict.__setitem__("__mul__", new OperatorFunctions("__mul__", 5, 2)); dict.__setitem__("mul", new OperatorFunctions("mul", 5, 2)); - dict.__setitem__("__repeat__", - new OperatorFunctions("__repeat__", 5, 2)); + dict.__setitem__("__repeat__", new OperatorFunctions("__repeat__", 5, 2)); dict.__setitem__("repeat", new OperatorFunctions("repeat", 5, 2)); dict.__setitem__("__or__", new OperatorFunctions("__or__", 6, 2)); dict.__setitem__("or_", new OperatorFunctions("or_", 6, 2)); - dict.__setitem__("__rshift__", - new OperatorFunctions("__rshift__", 7, 2)); + dict.__setitem__("__rshift__", new OperatorFunctions("__rshift__", 7, 2)); dict.__setitem__("rshift", new OperatorFunctions("rshift", 7, 2)); dict.__setitem__("__sub__", new OperatorFunctions("__sub__", 8, 2)); dict.__setitem__("sub", new OperatorFunctions("sub", 8, 2)); @@ -162,63 +166,43 @@ dict.__setitem__("__pos__", new OperatorFunctions("__pos__", 14, 1)); dict.__setitem__("pos", new OperatorFunctions("pos", 14, 1)); dict.__setitem__("truth", new OperatorFunctions("truth", 15, 1)); - dict.__setitem__("isCallable", - new OperatorFunctions("isCallable", 16, 1)); - dict.__setitem__("isMappingType", - new OperatorFunctions("isMappingType", 17, 1)); - dict.__setitem__("isNumberType", - new OperatorFunctions("isNumberType", 18, 1)); - dict.__setitem__("isSequenceType", - new OperatorFunctions("isSequenceType", 19, 1)); - dict.__setitem__("contains", - new OperatorFunctions("contains", 20, 2)); - dict.__setitem__("__contains__", - new OperatorFunctions("__contains__", 20, 2)); - dict.__setitem__("sequenceIncludes", - new OperatorFunctions("sequenceIncludes", 20, 2)); - dict.__setitem__("__delitem__", - new OperatorFunctions("__delitem__", 21, 2)); + dict.__setitem__("isCallable", new OperatorFunctions("isCallable", 16, 1)); + dict.__setitem__("isMappingType", new OperatorFunctions("isMappingType", 17, 1)); + dict.__setitem__("isNumberType", new OperatorFunctions("isNumberType", 18, 1)); + dict.__setitem__("isSequenceType", new OperatorFunctions("isSequenceType", 19, 1)); + dict.__setitem__("contains", new OperatorFunctions("contains", 20, 2)); + dict.__setitem__("__contains__", new OperatorFunctions("__contains__", 20, 2)); + dict.__setitem__("sequenceIncludes", new OperatorFunctions("sequenceIncludes", 20, 2)); + dict.__setitem__("__delitem__", new OperatorFunctions("__delitem__", 21, 2)); dict.__setitem__("delitem", new OperatorFunctions("delitem", 21, 2)); - dict.__setitem__("__delslice__", - new OperatorFunctions("__delslice__", 22, 3)); - dict.__setitem__("delslice", - new OperatorFunctions("delslice", 22, 3)); - dict.__setitem__("__getitem__", - new OperatorFunctions("__getitem__", 23, 2)); + dict.__setitem__("__delslice__", new OperatorFunctions("__delslice__", 22, 3)); + dict.__setitem__("delslice", new OperatorFunctions("delslice", 22, 3)); + dict.__setitem__("__getitem__", new OperatorFunctions("__getitem__", 23, 2)); dict.__setitem__("getitem", new OperatorFunctions("getitem", 23, 2)); - dict.__setitem__("__getslice__", - new OperatorFunctions("__getslice__", 24, 3)); - dict.__setitem__("getslice", - new OperatorFunctions("getslice", 24, 3)); - dict.__setitem__("__setitem__", - new OperatorFunctions("__setitem__", 25, 3)); + dict.__setitem__("__getslice__", new OperatorFunctions("__getslice__", 24, 3)); + dict.__setitem__("getslice", new OperatorFunctions("getslice", 24, 3)); + dict.__setitem__("__setitem__", new OperatorFunctions("__setitem__", 25, 3)); dict.__setitem__("setitem", new OperatorFunctions("setitem", 25, 3)); - dict.__setitem__("__setslice__", - new OperatorFunctions("__setslice__", 26, 4)); - dict.__setitem__("setslice", - new OperatorFunctions("setslice", 26, 4)); + dict.__setitem__("__setslice__", new OperatorFunctions("__setslice__", 26, 4)); + dict.__setitem__("setslice", new OperatorFunctions("setslice", 26, 4)); dict.__setitem__("ge", new OperatorFunctions("ge", 27, 2)); dict.__setitem__("__ge__", new OperatorFunctions("__ge__", 27, 2)); dict.__setitem__("le", new OperatorFunctions("le", 28, 2)); dict.__setitem__("__le__", new OperatorFunctions("__le__", 28, 2)); dict.__setitem__("eq", new OperatorFunctions("eq", 29, 2)); dict.__setitem__("__eq__", new OperatorFunctions("__eq__", 29, 2)); - dict.__setitem__("floordiv", - new OperatorFunctions("floordiv", 30, 2)); - dict.__setitem__("__floordiv__", - new OperatorFunctions("__floordiv__", 30, 2)); + dict.__setitem__("floordiv", new OperatorFunctions("floordiv", 30, 2)); + dict.__setitem__("__floordiv__", new OperatorFunctions("__floordiv__", 30, 2)); dict.__setitem__("gt", new OperatorFunctions("gt", 31, 2)); dict.__setitem__("__gt__", new OperatorFunctions("__gt__", 31, 2)); dict.__setitem__("invert", new OperatorFunctions("invert", 32, 1)); - dict.__setitem__("__invert__", - new OperatorFunctions("__invert__", 32, 1)); + dict.__setitem__("__invert__", new OperatorFunctions("__invert__", 32, 1)); dict.__setitem__("lt", new OperatorFunctions("lt", 33, 2)); dict.__setitem__("__lt__", new OperatorFunctions("__lt__", 33, 2)); dict.__setitem__("ne", new OperatorFunctions("ne", 34, 2)); dict.__setitem__("__ne__", new OperatorFunctions("__ne__", 34, 2)); dict.__setitem__("truediv", new OperatorFunctions("truediv", 35, 2)); - dict.__setitem__("__truediv__", - new OperatorFunctions("__truediv__", 35, 2)); + dict.__setitem__("__truediv__", new OperatorFunctions("__truediv__", 35, 2)); dict.__setitem__("pow", new OperatorFunctions("pow", 36, 2)); dict.__setitem__("__pow__", new OperatorFunctions("pow", 36, 2)); dict.__setitem__("is_", new OperatorFunctions("is_", 37, 2)); @@ -288,7 +272,7 @@ */ @ExposedType(name = "operator.attrgetter", isBaseType = false) static class PyAttrGetter extends PyObject { - + public static final PyType TYPE = PyType.fromClass(PyAttrGetter.class); public PyObject[] attrs; @@ -296,7 +280,7 @@ public PyAttrGetter(PyObject[] attrs) { this.attrs = attrs; } - + @ExposedNew final static PyObject attrgetter___new__(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords) { @@ -351,7 +335,7 @@ */ @ExposedType(name = "operator.itemgetter", isBaseType = false) static class PyItemGetter extends PyObject { - + public static final PyType TYPE = PyType.fromClass(PyItemGetter.class); public PyObject[] items; @@ -359,7 +343,7 @@ public PyItemGetter(PyObject[] items) { this.items = items; } - + @ExposedNew final static PyObject itemgetter___new__(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-10 06:30:33
|
Revision: 5727 http://jython.svn.sourceforge.net/jython/?rev=5727&view=rev Author: cgroves Date: 2008-12-10 06:30:28 +0000 (Wed, 10 Dec 2008) Log Message: ----------- exceptions needs to extend PyObject to keep from being exposed as a descendent of Object Modified Paths: -------------- branches/newstyle-java-types/src/org/python/core/exceptions.java Modified: branches/newstyle-java-types/src/org/python/core/exceptions.java =================================================================== --- branches/newstyle-java-types/src/org/python/core/exceptions.java 2008-12-10 00:07:22 UTC (rev 5726) +++ branches/newstyle-java-types/src/org/python/core/exceptions.java 2008-12-10 06:30:28 UTC (rev 5727) @@ -10,7 +10,7 @@ * The builtin exceptions module. The entire module should be imported from * python. None of the methods defined here should be called from java. */ -public class exceptions implements ClassDictInit { +public class exceptions extends PyObject implements ClassDictInit { public static String __doc__ = "Python's standard exception class hierarchy.\n" + "\n" @@ -138,7 +138,7 @@ buildClass(dict, "StopIteration", "Exception", "Signal the end from iterator.next()."); - + buildClass(dict, "GeneratorExit", "Exception", "Request that a generator exit."); buildClass(dict, "Warning", "Exception", "Base class for warning categories."); @@ -148,7 +148,7 @@ buildClass(dict, "DeprecationWarning", "Warning", "Base class for warnings about deprecated features."); - + buildClass(dict, "PendingDeprecationWarning", "Warning", "Base class for warnings about features which will be deprecated\n" + "in the future."); @@ -342,7 +342,7 @@ // NOTE: UnicodeError doesn't actually use its own constructor return dict; } - + public static void UnicodeError__init__(PyObject self, PyObject[] args, String[] kwargs, PyType objectType) { ArgParser ap = new ArgParser("__init__", args, kwargs, @@ -363,7 +363,7 @@ dict.__setitem__("__str__", bindStaticJavaMethod("__str__", "UnicodeDecodeError__str__")); return dict; } - + public static void UnicodeDecodeError__init__(PyObject self, PyObject[] args, String[] kwargs) { PyBaseException.TYPE.invoke("__init__", self, args, kwargs); @@ -397,7 +397,7 @@ dict.__setitem__("__str__", bindStaticJavaMethod("__str__", "UnicodeEncodeError__str__")); return dict; } - + public static void UnicodeEncodeError__init__(PyObject self, PyObject[] args, String[] kwargs) { PyBaseException.TYPE.invoke("__init__", self, args, kwargs); UnicodeError__init__(self, args, kwargs, PyUnicode.TYPE); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-12-10 00:07:25
|
Revision: 5726 http://jython.svn.sourceforge.net/jython/?rev=5726&view=rev Author: pjenvey Date: 2008-12-10 00:07:22 +0000 (Wed, 10 Dec 2008) Log Message: ----------- match CPython's dir() more closely fixes #1196 pointed out by doublep Modified Paths: -------------- trunk/jython/Lib/test/test_builtin_jy.py trunk/jython/src/org/python/core/PyClass.java trunk/jython/src/org/python/core/PyObject.java trunk/jython/src/org/python/core/PyType.java Modified: trunk/jython/Lib/test/test_builtin_jy.py =================================================================== --- trunk/jython/Lib/test/test_builtin_jy.py 2008-12-09 22:25:56 UTC (rev 5725) +++ trunk/jython/Lib/test/test_builtin_jy.py 2008-12-10 00:07:22 UTC (rev 5726) @@ -16,6 +16,13 @@ raise TypeError() self.assert_(not hasattr(Foo(), 'bar')) + def test_dir(self): + # for http://bugs.jython.org/issue1063 + class Foo(object): + def __getattribute__(self, name): + return name + self.assertEqual(dir(Foo()), []) + class LoopTest(unittest.TestCase): def test_break(self): Modified: trunk/jython/src/org/python/core/PyClass.java =================================================================== --- trunk/jython/src/org/python/core/PyClass.java 2008-12-09 22:25:56 UTC (rev 5725) +++ trunk/jython/src/org/python/core/PyClass.java 2008-12-10 00:07:22 UTC (rev 5726) @@ -281,11 +281,7 @@ } public void __rawdir__(PyDictionary accum) { - addKeys(accum, "__dict__"); - PyObject[] bases = __bases__.getArray(); - for (PyObject base : bases) { - base.__rawdir__(accum); - } + mergeClassDict(accum, this); } /** Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2008-12-09 22:25:56 UTC (rev 5725) +++ trunk/jython/src/org/python/core/PyObject.java 2008-12-10 00:07:22 UTC (rev 5726) @@ -903,24 +903,54 @@ return __findattr__(name); } - protected void addKeys(PyDictionary accum, String attr) { + protected void mergeListAttr(PyDictionary accum, String attr) { PyObject obj = __findattr__(attr); - if (obj == null) + if (obj == null) { return; + } if (obj instanceof PyList) { for (PyObject name : obj.asIterable()) { accum.__setitem__(name, Py.None); } - } else { + } + } + + protected void mergeDictAttr(PyDictionary accum, String attr) { + PyObject obj = __findattr__(attr); + if (obj == null) { + return; + } + if (obj instanceof PyDictionary || obj instanceof PyStringMap + || obj instanceof PyDictProxy) { accum.update(obj); } } + protected void mergeClassDict(PyDictionary accum, PyObject aClass) { + // Merge in the type's dict (if any) + aClass.mergeDictAttr(accum, "__dict__"); + + // Recursively merge in the base types' (if any) dicts + PyObject bases = aClass.__findattr__("__bases__"); + if (bases == null) { + return; + } + // We have no guarantee that bases is a real tuple + int len = bases.__len__(); + for (int i = 0; i < len; i++) { + mergeClassDict(accum, bases.__getitem__(i)); + } + } + protected void __rawdir__(PyDictionary accum) { - addKeys(accum, "__dict__"); - addKeys(accum, "__methods__"); - addKeys(accum, "__members__"); - fastGetClass().__rawdir__(accum); + mergeDictAttr(accum, "__dict__"); + mergeListAttr(accum, "__methods__"); + mergeListAttr(accum, "__members__"); + // Class dict is a slower, more manual merge to match CPython + PyObject itsClass = __findattr__("__class__"); + if (itsClass != null) { + mergeClassDict(accum, itsClass); + } } /** Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2008-12-09 22:25:56 UTC (rev 5725) +++ trunk/jython/src/org/python/core/PyType.java 2008-12-10 00:07:22 UTC (rev 5726) @@ -1129,13 +1129,7 @@ } protected void __rawdir__(PyDictionary accum) { - PyObject[] mro = this.mro; - if (mro == null) { - return; - } - for (PyObject element : mro) { - element.addKeys(accum, "__dict__"); - } + mergeClassDict(accum, this); } public String fastGetName() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-12-09 22:26:01
|
Revision: 5725 http://jython.svn.sourceforge.net/jython/?rev=5725&view=rev Author: pjenvey Date: 2008-12-09 22:25:56 +0000 (Tue, 09 Dec 2008) Log Message: ----------- these are no longer used 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-12-09 21:56:51 UTC (rev 5724) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2008-12-09 22:25:56 UTC (rev 5725) @@ -633,17 +633,6 @@ } } - private boolean inFinallyBody() { - for (int i = 0; i < exceptionHandlers.size(); ++i) { - ExceptionHandler handler = - (ExceptionHandler)exceptionHandlers.elementAt(i); - if (handler.isFinallyHandler()) { - return true; - } - } - return false; - } - private void restoreLocals() throws Exception { endExceptionHandlers(); @@ -1490,7 +1479,6 @@ public static int makeStrings(Code c, Collection<String> names) throws IOException { - int n = 0; if (names != null) { c.iconst(names.size()); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-12-09 21:56:55
|
Revision: 5724 http://jython.svn.sourceforge.net/jython/?rev=5724&view=rev Author: pjenvey Date: 2008-12-09 21:56:51 +0000 (Tue, 09 Dec 2008) Log Message: ----------- o allow overriding of ExceptionHandler's inline finally block o fix the with statement's normal finally/exit block so it also happens for non local gotos (e.g. return, continue) o modify test_with instead of adding test_with_jy to test for this case -- the lack of these tests is really a test bug IMO fixes #1194 pointed out by Terrence Cole Modified Paths: -------------- trunk/jython/Lib/test/test_with.py trunk/jython/src/org/python/compiler/CodeCompiler.java Modified: trunk/jython/Lib/test/test_with.py =================================================================== --- trunk/jython/Lib/test/test_with.py 2008-12-09 08:45:33 UTC (rev 5723) +++ trunk/jython/Lib/test/test_with.py 2008-12-09 21:56:51 UTC (rev 5724) @@ -506,59 +506,70 @@ self.assertRaises(GeneratorExit, shouldThrow) -class NonLocalFlowControlTestCase(unittest.TestCase): +class NonLocalFlowControlTestCase(unittest.TestCase, + ContextmanagerAssertionMixin): def testWithBreak(self): + mock = mock_contextmanager_generator() counter = 0 while True: counter += 1 - with mock_contextmanager_generator(): + with mock: counter += 10 break counter += 100 # Not reached self.assertEqual(counter, 11) + self.assertAfterWithManagerInvariantsNoError(mock) def testWithContinue(self): + mock = mock_contextmanager_generator() counter = 0 while True: counter += 1 if counter > 2: break - with mock_contextmanager_generator(): + with mock: counter += 10 continue counter += 100 # Not reached self.assertEqual(counter, 12) + self.assertAfterWithManagerInvariantsNoError(mock) def testWithReturn(self): + mock = mock_contextmanager_generator() def foo(): counter = 0 while True: counter += 1 - with mock_contextmanager_generator(): + with mock: counter += 10 return counter counter += 100 # Not reached self.assertEqual(foo(), 11) + self.assertAfterWithManagerInvariantsNoError(mock) def testWithYield(self): + mock = mock_contextmanager_generator() def gen(): - with mock_contextmanager_generator(): + with mock: yield 12 yield 13 x = list(gen()) self.assertEqual(x, [12, 13]) + self.assertAfterWithManagerInvariantsNoError(mock) def testWithRaise(self): + mock = mock_contextmanager_generator() counter = 0 try: counter += 1 - with mock_contextmanager_generator(): + with mock: counter += 10 raise RuntimeError counter += 100 # Not reached except RuntimeError: self.assertEqual(counter, 11) + self.assertAfterWithManagerInvariants(mock, sys.exc_info()) else: self.fail("Didn't raise RuntimeError") Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2008-12-09 08:45:33 UTC (rev 5723) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2008-12-09 21:56:51 UTC (rev 5724) @@ -1225,7 +1225,7 @@ // also exiting the try: portion of this particular finally } if (handler.isFinallyHandler()) { - suite(((TryFinally) handler.node).getInternalFinalbody()); + handler.finalBody(this); } } @@ -2245,15 +2245,14 @@ throw new ParseException("'with' will become a reserved keyword in Python 2.6", node); } - Label label_body_start = new Label(); - Label label_body_end = new Label(); - Label label_catch = new Label(); - Label label_finally = new Label(); - Label label_end = new Label(); + final Label label_body_start = new Label(); + final Label label_body_end = new Label(); + final Label label_catch = new Label(); + final Label label_end = new Label(); - Method getattr = Method.getMethod("org.python.core.PyObject __getattr__ (String)"); - Method call = Method.getMethod("org.python.core.PyObject __call__ ()"); - Method call3 = Method.getMethod("org.python.core.PyObject __call__ (org.python.core.PyObject,org.python.core.PyObject,org.python.core.PyObject)"); + final Method getattr = Method.getMethod("org.python.core.PyObject __getattr__ (String)"); + final Method call = Method.getMethod("org.python.core.PyObject __call__ ()"); + final Method call3 = Method.getMethod("org.python.core.PyObject __call__ (org.python.core.PyObject,org.python.core.PyObject,org.python.core.PyObject)"); // mgr = (EXPR) visit(node.getInternalContext_expr()); @@ -2261,7 +2260,7 @@ code.ldc("__exit__"); code.invokevirtual(Type.getType(PyObject.class).getInternalName(), getattr.getName(), getattr.getDescriptor()); - int __exit__ = code.getLocal("org/python/core/PyObject"); + final int __exit__ = code.getLocal("org/python/core/PyObject"); code.astore(__exit__); // value = mgr.__enter__() @@ -2272,11 +2271,34 @@ code.astore(value_tmp); // exc = True # not necessary, since we don't exec finally if exception + + // FINALLY (preparation) + // ordinarily with a finally, we need to duplicate the code. that's not the case + // here + // # The normal and non-local-goto cases are handled here + // if exc: # implicit + // exit(None, None, None) + ExceptionHandler normalExit = new ExceptionHandler() { + @Override + public boolean isFinallyHandler() { return true; } + + @Override + public void finalBody(CodeCompiler compiler) throws Exception { + compiler.code.aload(__exit__); + compiler.getNone(); + compiler.code.dup(); + compiler.code.dup(); + compiler.code.invokevirtual(Type.getType(PyObject.class).getInternalName(), + call3.getName(), call3.getDescriptor()); + compiler.code.pop(); + } + }; + exceptionHandlers.push(normalExit); + // try-catch block here - //code.trycatch(label_body_start, label_body_end, label_catch, "java/lang/Throwable"); ExceptionHandler handler = new ExceptionHandler(); + exceptionHandlers.push(handler); handler.exceptionStarts.addElement(label_body_start); - exceptionHandlers.push(handler); // VAR = value # Only if "as VAR" is present code.label(label_body_start); @@ -2285,13 +2307,22 @@ } code.freeLocal(value_tmp); - // BLOCK - suite(node.getInternalBody()); + // BLOCK + FINALLY if non-local-goto + Object blockResult = suite(node.getInternalBody()); + normalExit.bodyDone = true; exceptionHandlers.pop(); - code.goto_(label_finally); + exceptionHandlers.pop(); code.label(label_body_end); handler.exceptionEnds.addElement(label_body_end); + // FINALLY if *not* non-local-goto + if (blockResult == NoExit) { + // BLOCK would have generated FINALLY for us if it exited (due to a break, + // continue or return) + inlineFinally(normalExit); + code.goto_(label_end); + } + // CATCH code.label(label_catch); @@ -2322,29 +2353,12 @@ code.invokestatic("org/python/core/Py", "makeException", "()Lorg/python/core/PyException;"); code.checkcast("java/lang/Throwable"); code.athrow(); - code.freeLocal(ts_tmp); - - handler.addExceptionHandlers(label_catch); - // FINALLY - // ordinarily with a finally, we need to duplicate the code. that's not the case here - // # The normal and non-local-goto cases are handled here - // if exc: # implicit - // exit(None, None, None) - - code.label(label_finally); - - code.aload(__exit__); - getNone(); - code.dup(); - code.dup(); - code.invokevirtual(Type.getType(PyObject.class).getInternalName(), call3.getName(), call3.getDescriptor()); - code.pop(); - code.label(label_end); code.freeLocal(__exit__); + handler.addExceptionHandlers(label_catch); return null; } @@ -2405,5 +2419,11 @@ } } } + + public void finalBody(CodeCompiler compiler) throws Exception { + if (node instanceof TryFinally) { + suite(((TryFinally)node).getInternalFinalbody()); + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-12-09 08:45:37
|
Revision: 5723 http://jython.svn.sourceforge.net/jython/?rev=5723&view=rev Author: pjenvey Date: 2008-12-09 08:45:33 +0000 (Tue, 09 Dec 2008) Log Message: ----------- avoid an NPE when getSQLState is null thanks Matthew Harrison Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/zxJDBC.java Modified: trunk/jython/src/com/ziclix/python/sql/zxJDBC.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/zxJDBC.java 2008-12-08 19:44:12 UTC (rev 5722) +++ trunk/jython/src/com/ziclix/python/sql/zxJDBC.java 2008-12-09 08:45:33 UTC (rev 5723) @@ -336,8 +336,9 @@ String state = ((SQLException)throwable).getSQLState(); // The SQL standard is not freely available, but // http://www.postgresql.org/docs/current/static/errcodes-appendix.html - // contains most of the SQLSTATES codes - if (state.length() == 5) { // Otherwise, the state is not following the standard. + // contains most of the SQLSTATES codes. + // Otherwise, the state is not following the standard. + if (state != null && state.length() == 5) { if (state.startsWith("23")) { //Class 23 => Integrity Constraint Violation type = IntegrityError; } else if (state.equals("40002")) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |