File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -190,7 +190,8 @@ impl ByteInnerPaddingOptions {
190190 . ok_or_else ( || {
191191 vm. new_type_error ( format ! (
192192 "{}() argument 2 must be a byte string of length 1, not {}" ,
193- fn_name, & v
193+ fn_name,
194+ v. class( ) . name( )
194195 ) )
195196 } ) ?
196197 } else {
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ macro_rules! py_namespace {
101101/// let int_value = match_class!(match obj {
102102/// i @ PyInt => i.as_bigint().clone(),
103103/// f @ PyFloat => f.to_f64().to_bigint().unwrap(),
104- /// obj => panic!("non-numeric object {}", obj),
104+ /// obj => panic!("non-numeric object {:? }", obj),
105105/// });
106106///
107107/// assert!(int_value.is_zero());
Original file line number Diff line number Diff line change @@ -29,18 +29,6 @@ Basically reference counting, but then done by rust.
2929/// since exceptions are also python objects.
3030pub type PyResult < T = PyObjectRef > = Result < T , PyBaseExceptionRef > ; // A valid value, or an exception
3131
32- // TODO: remove these 2 impls
33- impl fmt:: Display for PyObjectRef {
34- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
35- ( * * self ) . fmt ( f)
36- }
37- }
38- impl fmt:: Display for PyObject {
39- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
40- write ! ( f, "'{}' object" , self . class( ) . name( ) )
41- }
42- }
43-
4432impl < T : fmt:: Display > fmt:: Display for PyRef < T >
4533where
4634 T : PyObjectPayload + fmt:: Display ,
Original file line number Diff line number Diff line change @@ -184,7 +184,13 @@ impl PyObject {
184184
185185 pub fn generic_getattr ( & self , name : PyStrRef , vm : & VirtualMachine ) -> PyResult {
186186 self . generic_getattr_opt ( name. clone ( ) , None , vm) ?
187- . ok_or_else ( || vm. new_attribute_error ( format ! ( "{} has no attribute '{}'" , self , name) ) )
187+ . ok_or_else ( || {
188+ vm. new_attribute_error ( format ! (
189+ "'{}' object has no attribute '{}'" ,
190+ self . class( ) . name( ) ,
191+ name
192+ ) )
193+ } )
188194 }
189195
190196 /// CPython _PyObject_GenericGetAttrWithDict
@@ -527,8 +533,12 @@ impl PyObject {
527533 }
528534
529535 pub fn length ( & self , vm : & VirtualMachine ) -> PyResult < usize > {
530- self . length_opt ( vm)
531- . ok_or_else ( || vm. new_type_error ( format ! ( "object of type '{}' has no len()" , & self ) ) ) ?
536+ self . length_opt ( vm) . ok_or_else ( || {
537+ vm. new_type_error ( format ! (
538+ "object of type '{}' has no len()" ,
539+ self . class( ) . name( )
540+ ) )
541+ } ) ?
532542 }
533543
534544 pub fn get_item < K : DictKey + ?Sized > ( & self , needle : & K , vm : & VirtualMachine ) -> PyResult {
Original file line number Diff line number Diff line change @@ -349,7 +349,7 @@ pub(crate) mod _thread {
349349 . ok_or_else ( || {
350350 vm. new_attribute_error ( format ! (
351351 "{} has no attribute '{}'" ,
352- zelf. as_object ( ) ,
352+ zelf. class ( ) . name ( ) ,
353353 attr
354354 ) )
355355 } )
@@ -367,7 +367,7 @@ pub(crate) mod _thread {
367367 if attr. as_str ( ) == "__dict__" {
368368 Err ( vm. new_attribute_error ( format ! (
369369 "{} attribute '__dict__' is read-only" ,
370- zelf. as_object ( )
370+ zelf. class ( ) . name ( )
371371 ) ) )
372372 } else {
373373 let dict = zelf. ldict ( vm) ;
Original file line number Diff line number Diff line change @@ -416,7 +416,7 @@ impl VirtualMachine {
416416 . unwrap_or_else ( |_| panic ! ( "unable to import {}" , module) ) ;
417417 let class = module
418418 . get_attr ( class, self )
419- . unwrap_or_else ( |_| panic ! ( "module {} has no class {}" , module, class) ) ;
419+ . unwrap_or_else ( |_| panic ! ( "module {:? } has no class {}" , module, class) ) ;
420420 class. downcast ( ) . expect ( "not a class" )
421421 }
422422
You can’t perform that action at this time.
0 commit comments