From: <pj...@us...> - 2008-10-15 00:46:13
|
Revision: 5394 http://jython.svn.sourceforge.net/jython/?rev=5394&view=rev Author: pjenvey Date: 2008-10-15 00:46:02 +0000 (Wed, 15 Oct 2008) Log Message: ----------- fix solid_base considering slotted objects with a __dict__ as solid Modified Paths: -------------- trunk/jython/Lib/test/test_class_jy.py trunk/jython/src/org/python/core/PyType.java Modified: trunk/jython/Lib/test/test_class_jy.py =================================================================== --- trunk/jython/Lib/test/test_class_jy.py 2008-10-14 23:08:45 UTC (rev 5393) +++ trunk/jython/Lib/test/test_class_jy.py 2008-10-15 00:46:02 UTC (rev 5394) @@ -162,6 +162,18 @@ class Bar(SlottedBase): __metaclass__ = Meta + def test_slotted_diamond_problem_bug(self): + class A(object): + __slots__ = 'foo' + class B(A): + pass + class C(A): + pass + # used to raise TypeError: multiple bases have instance lay-out + # conflict + class D(B, C): + pass + class ClassNamelessModuleTestCase(unittest.TestCase): Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2008-10-14 23:08:45 UTC (rev 5393) +++ trunk/jython/src/org/python/core/PyType.java 2008-10-15 00:46:02 UTC (rev 5394) @@ -823,7 +823,8 @@ } /** - * Finds the parent of type with an underlying_class or with slots. + * Finds the parent of type with an underlying_class or with slots sans a __dict__ + * slot. */ private static PyType solid_base(PyType type) { do { @@ -836,7 +837,7 @@ } private static boolean isSolidBase(PyType type) { - return type.underlying_class != null || type.numSlots != 0; + return type.underlying_class != null || (type.numSlots != 0 && !type.needs_userdict); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |