Created
September 28, 2013 07:01
-
-
Save ironpythonbot/6739351 to your computer and use it in GitHub Desktop.
CodePlex Issue #33663 Plain Text Attachments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Languages/IronPython/IronPython/Runtime/Super.cs b/Languages/IronPython/IronPython/Runtime/Super.cs | |
index eddb18a..2bdbac3 100644 | |
--- a/Languages/IronPython/IronPython/Runtime/Super.cs | |
+++ b/Languages/IronPython/IronPython/Runtime/Super.cs | |
@@ -170,8 +170,8 @@ namespace IronPython.Runtime { | |
private PythonType DescriptorContext { | |
get { | |
- if (!DynamicHelpers.GetPythonType(_self).IsSubclassOf(_thisClass)) { | |
- return _thisClass; | |
+ if (!(DynamicHelpers.GetPythonType(_self).IsSubclassOf(_thisClass))) { | |
+ return _selfClass as PythonType ?? _thisClass; | |
} | |
PythonType dt = _selfClass as PythonType; | |
diff --git a/Languages/IronPython/Tests/test_super.py b/Languages/IronPython/Tests/test_super.py | |
new file mode 100644 | |
index 0000000..8f8b2b3 | |
--- /dev/null | |
+++ b/Languages/IronPython/Tests/test_super.py | |
@@ -0,0 +1,61 @@ | |
+##################################################################################### | |
+# | |
+# Copyright (c) Michael van der Kolff. All rights reserved. | |
+# | |
+# This source code is subject to terms and conditions of the Apache License, Version 2.0. A | |
+# copy of the license can be found in the License.html file at the root of this distribution. If | |
+# you cannot locate the Apache License, Version 2.0, please send an email to | |
+# ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound | |
+# by the terms of the Apache License, Version 2.0. | |
+# | |
+# You must not remove this notice, or any other, from this software. | |
+# | |
+# | |
+##################################################################################### | |
+ | |
+## | |
+## Test whether super() behaves as expected | |
+## | |
+ | |
+from iptest.assert_util import * | |
+ | |
+class A(object): | |
+ """Doc string A""" | |
+ @classmethod | |
+ def cls_getDoc(cls): | |
+ return cls.__doc__ | |
+ | |
+ def inst_getDoc(self): | |
+ return self.__doc__ | |
+ | |
+class B(A): | |
+ """Doc string B""" | |
+ @classmethod | |
+ def cls_getDoc(cls): | |
+ return super(B,cls).cls_getDoc() | |
+ | |
+ def inst_getDoc(self): | |
+ return super(B,self).inst_getDoc() | |
+ | |
+class C(B): | |
+ """Doc string C""" | |
+ pass | |
+ | |
+class D(B): | |
+ """Doc string D""" | |
+ @classmethod | |
+ def cls_getDoc(cls): | |
+ return super(D,cls).cls_getDoc() | |
+ | |
+ def inst_getDoc(self): | |
+ return super(D,self).inst_getDoc() | |
+ | |
+def test_classSupermethods(): | |
+ for cls in (A,B,C,D): | |
+ AreEqual(cls.cls_getDoc(), cls.__doc__) | |
+ | |
+def test_instanceSupermethods(): | |
+ for cls in (A,B,C,D): | |
+ AreEqual(cls().inst_getDoc(), cls.__doc__) | |
+ | |
+run_test(__name__) | |
diff --git a/Test/IronPython.tests b/Test/IronPython.tests | |
index 6996f65..5ef48e8 100644 | |
--- a/Test/IronPython.tests | |
+++ b/Test/IronPython.tests | |
@@ -197,6 +197,17 @@ | |
<WorkingDirectory>%DLR_ROOT%\Languages\IronPython\Tests</WorkingDirectory> | |
</Test> | |
<Test> | |
+ <Name>test_super_20</Name> | |
+ <Filename>%DLR_ROOT%\Languages\IronPython\Internal\ipy.bat</Filename> | |
+ <Arguments>test_super.py</Arguments> | |
+ <MaxDuration>600000</MaxDuration> | |
+ <LongRunning>false</LongRunning> | |
+ <Disabled>false</Disabled> | |
+ <RequiresAdmin>false</RequiresAdmin> | |
+ <NotParallelSafe>false</NotParallelSafe> | |
+ <WorkingDirectory>%DLR_ROOT%\Languages\IronPython\Tests</WorkingDirectory> | |
+ </Test> | |
+ <Test> | |
<Name>test_tuple_20</Name> | |
<Filename>%DLR_ROOT%\Languages\IronPython\Internal\ipy.bat</Filename> | |
<Arguments>test_tuple.py</Arguments> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A(object): | |
"""A funny class A""" | |
@classmethod | |
def x(cls): | |
print cls.__doc__ | |
class B(A): | |
"""B funny class B""" | |
@classmethod | |
def x(cls): | |
super(B,cls).x() | |
class C(B): | |
"""C funny class C""" | |
pass | |
class D(B): | |
"""D funny class D""" | |
@classmethod | |
def x(cls): | |
super(D,cls).x() | |
if __name__ == "__main__": | |
B.x() | |
C.x() | |
D.x() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment