File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ impl PyClassMethod {
195195impl Representable for PyClassMethod {
196196 #[ inline]
197197 fn repr_str ( zelf : & Py < Self > , vm : & VirtualMachine ) -> PyResult < String > {
198- let callable = zelf. callable . lock ( ) . repr ( vm) . unwrap ( ) ;
198+ let callable = zelf. callable . lock ( ) . repr ( vm) ? ;
199199 let class = Self :: class ( & vm. ctx ) ;
200200
201201 let repr = match (
Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ impl Callable for PyStaticMethod {
179179
180180impl Representable for PyStaticMethod {
181181 fn repr_str ( zelf : & Py < Self > , vm : & VirtualMachine ) -> PyResult < String > {
182- let callable = zelf. callable . lock ( ) . repr ( vm) . unwrap ( ) ;
182+ let callable = zelf. callable . lock ( ) . repr ( vm) ? ;
183183 let class = Self :: class ( & vm. ctx ) ;
184184
185185 match (
Original file line number Diff line number Diff line change @@ -163,6 +163,29 @@ def t1(self):
163163cm = classmethod (lambda cls : cls )
164164assert cm .__func__ (int ) is int
165165
166+
167+ class Callback :
168+ def __init__ (self , error ):
169+ self .error = error
170+
171+ def __call__ (self , * args , ** kwargs ):
172+ pass
173+
174+ def __repr__ (self ):
175+ raise self .error
176+
177+
178+ callback = Callback (RuntimeError ("callback is unavailable" ))
179+
180+ with assert_raises (RuntimeError ) as caught :
181+ repr (staticmethod (callback ))
182+ assert caught .exception is callback .error
183+
184+ with assert_raises (RuntimeError ) as caught :
185+ repr (classmethod (callback ))
186+ assert caught .exception is callback .error
187+
188+
166189assert str (super (int , 5 )) == "<super: <class 'int'>, <int object>>"
167190
168191class T5 (int ):
You can’t perform that action at this time.
0 commit comments