File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ test_super_list = super (list )
2+ assert test_super_list .__self__ is None
3+ assert test_super_list .__self_class__ is None
4+ assert test_super_list .__thisclass__ == list
5+
6+
7+ class testA :
8+ a = 1
9+
10+
11+ class testB (testA ):
12+ b = 1
13+
14+
15+ superB = super (testB )
16+ assert superB .__thisclass__ == testB
17+ assert superB .__self_class__ is None
18+ assert superB .__self__ is None
Original file line number Diff line number Diff line change @@ -114,6 +114,16 @@ impl PySuper {
114114 self . typ . clone ( )
115115 }
116116
117+ #[ pyproperty( magic) ]
118+ fn self_class ( & self ) -> Option < PyTypeRef > {
119+ Some ( self . obj . as_ref ( ) ?. 1 . clone ( ) )
120+ }
121+
122+ #[ pyproperty]
123+ fn __self__ ( & self ) -> Option < PyObjectRef > {
124+ Some ( self . obj . as_ref ( ) ?. 0 . clone ( ) )
125+ }
126+
117127 #[ pymethod( magic) ]
118128 fn repr ( & self ) -> String {
119129 let typname = & self . typ . name ( ) ;
You can’t perform that action at this time.
0 commit comments