From: <pj...@us...> - 2009-11-25 08:48:39
|
Revision: 6950 http://jython.svn.sourceforge.net/jython/?rev=6950&view=rev Author: pjenvey Date: 2009-11-25 08:48:20 +0000 (Wed, 25 Nov 2009) Log Message: ----------- correct the fix for #1297 (r6263) to avoid potentially adding the type's proxy to its mro twice fixes #1504 Modified Paths: -------------- trunk/jython/Lib/test/test_java_subclasses.py trunk/jython/NEWS trunk/jython/src/org/python/core/PyType.java Modified: trunk/jython/Lib/test/test_java_subclasses.py =================================================================== --- trunk/jython/Lib/test/test_java_subclasses.py 2009-11-24 02:15:34 UTC (rev 6949) +++ trunk/jython/Lib/test/test_java_subclasses.py 2009-11-25 08:48:20 UTC (rev 6950) @@ -10,6 +10,7 @@ from java.util import Date, Hashtable, Vector from java.awt import Color, Component, Dimension, Rectangle +from javax.swing import ComboBoxModel, ListModel from javax.swing.table import AbstractTableModel from org.python.tests import BeanInterface, Callbacker, Coercions, OwnMethodCaller @@ -45,6 +46,15 @@ c.run() self.assertEquals(calls, ["ComparableRunner.compareTo", "Runner.run"]) + def test_inherit_interface_twice(self): + # http://bugs.jython.org/issue1504 + class A(ListModel): pass + class B(A, ComboBoxModel): pass + # Regression caused B's proxy to occur in B's mro twice. That + # caused the declaration of C to fail with an inconsistent mro + class C(B): pass + + class TableModelTest(unittest.TestCase): def test_class_coercion(self): '''Python type instances coerce to a corresponding Java wrapper type in Object.getClass''' @@ -328,3 +338,7 @@ PythonSubclassesTest, AbstractOnSyspathTest, ContextClassloaderTest) + + +if __name__ == '__main__': + test_main() Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2009-11-24 02:15:34 UTC (rev 6949) +++ trunk/jython/NEWS 2009-11-25 08:48:20 UTC (rev 6950) @@ -11,6 +11,7 @@ - [ 1499 ] PostgreSQL datahandler should return Decimals instead of floats for NUMERIC/DECIMAL columns - [ 1477 ] os.setpgrp and posix.setpgrp fail with TypeError - [ 1396 ] Assigning os module funcs as class attributes incompatible with CPython + - [ 1504 ] Inheriting twice from the same Java interface causes MRO problems - Fix runtime issues during exitfuncs triggered via SystemRestart (such as during Django or Pylons development mode reloading) Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2009-11-24 02:15:34 UTC (rev 6949) +++ trunk/jython/src/org/python/core/PyType.java 2009-11-25 08:48:20 UTC (rev 6950) @@ -891,6 +891,7 @@ PyObject[] computeMro(MROMergeState[] toMerge, List<PyObject> mro) { boolean addedProxy = false; + PyType proxyAsType = javaProxy == null ? null : PyType.fromClass(((Class<?>)javaProxy)); scan : for (int i = 0; i < toMerge.length; i++) { if (toMerge[i].isMerged()) { continue scan; @@ -911,14 +912,16 @@ // This exposes the methods from the proxy generated for this class in addition to // those generated for the superclass while allowing methods from the superclass to // remain visible from the proxies. + mro.add(proxyAsType); addedProxy = true; - mro.add(PyType.fromClass(((Class<?>)javaProxy))); } mro.add(candidate); + // Was that our own proxy? + addedProxy |= candidate == proxyAsType; for (MROMergeState element : toMerge) { element.noteMerged(candidate); } - i = -1;// restart scan + i = -1; // restart scan } for (MROMergeState mergee : toMerge) { if (!mergee.isMerged()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |