From ebbdde6568660f7bca429166559fb2a911e797c4 Mon Sep 17 00:00:00 2001 From: Anson Mansfield Date: Sat, 20 Jul 2024 10:50:42 -0400 Subject: [PATCH] tests/cpydiff/core_class: Document issue with super in classmethod. Signed-off-by: Anson Mansfield --- tests/cpydiff/core_class_superclassmethod.py | 45 ++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/cpydiff/core_class_superclassmethod.py diff --git a/tests/cpydiff/core_class_superclassmethod.py b/tests/cpydiff/core_class_superclassmethod.py new file mode 100644 index 0000000000000..eb6720b9f2a43 --- /dev/null +++ b/tests/cpydiff/core_class_superclassmethod.py @@ -0,0 +1,45 @@ +""" +categories: Core,Classes +description: super inside a classmethod defers to type rather than parent class. +cause: Unknown +workaround: Unknown +""" + + +class A: + @classmethod + def f(cls): + print("Af", cls.__name__) + + @classmethod + def g(cls): + print("Ag", cls.__name__) + + +class B(A): + @classmethod + def f(cls): + print("Bf", cls.__name__) + super().f() + + @classmethod + def g(cls): + print("Bg", cls.__name__) + super(B, cls).g() + + +class C(B): + @classmethod + def f(cls): + print("Cf", cls.__name__) + super().f() + + @classmethod + def g(cls): + print("Cg", cls.__name__) + super(C, cls).g() + + +c = C() +c.f() +c.g() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy