File tree 5 files changed +45
-7
lines changed 5 files changed +45
-7
lines changed Original file line number Diff line number Diff line change @@ -1211,11 +1211,18 @@ impl Frame {
1211
1211
1212
1212
impl fmt:: Debug for Frame {
1213
1213
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1214
+ trace ! ( "formatting stack" ) ;
1214
1215
let stack_str = self
1215
1216
. stack
1216
1217
. borrow ( )
1217
1218
. iter ( )
1218
- . map ( |elem| format ! ( "\n > {:?}" , elem) )
1219
+ . map ( |elem| {
1220
+ if elem. payload . as_any ( ) . is :: < Frame > ( ) {
1221
+ "\n > {frame}" . to_string ( )
1222
+ } else {
1223
+ format ! ( "\n > {:?}" , elem)
1224
+ }
1225
+ } )
1219
1226
. collect :: < String > ( ) ;
1220
1227
let block_str = self
1221
1228
. blocks
Original file line number Diff line number Diff line change 1
1
use std:: cell:: { Cell , RefCell } ;
2
2
use std:: collections:: HashMap ;
3
+ use std:: fmt;
3
4
use std:: ops:: { Deref , DerefMut } ;
4
5
5
6
use crate :: pyobject:: {
@@ -14,13 +15,20 @@ use super::objtype;
14
15
15
16
pub type DictContentType = HashMap < String , ( PyObjectRef , PyObjectRef ) > ;
16
17
17
- #[ derive( Default , Debug ) ]
18
+ #[ derive( Default ) ]
18
19
pub struct PyDict {
19
20
// TODO: should be private
20
21
pub entries : RefCell < DictContentType > ,
21
22
}
22
23
pub type PyDictRef = PyRef < PyDict > ;
23
24
25
+ impl fmt:: Debug for PyDict {
26
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
27
+ // TODO: implement more detailed, non-recursive Debug formatter
28
+ f. write_str ( "dict" )
29
+ }
30
+ }
31
+
24
32
impl PyValue for PyDict {
25
33
fn required_type ( ctx : & PyContext ) -> PyObjectRef {
26
34
ctx. dict_type ( )
Original file line number Diff line number Diff line change @@ -14,13 +14,21 @@ use crate::pyobject::{
14
14
} ;
15
15
use crate :: vm:: { ReprGuard , VirtualMachine } ;
16
16
use num_traits:: ToPrimitive ;
17
+ use std:: fmt;
17
18
18
- #[ derive( Debug , Default ) ]
19
+ #[ derive( Default ) ]
19
20
pub struct PyList {
20
21
// TODO: shouldn't be public
21
22
pub elements : RefCell < Vec < PyObjectRef > > ,
22
23
}
23
24
25
+ impl fmt:: Debug for PyList {
26
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
27
+ // TODO: implement more detailed, non-recursive Debug formatter
28
+ f. write_str ( "list" )
29
+ }
30
+ }
31
+
24
32
impl From < Vec < PyObjectRef > > for PyList {
25
33
fn from ( elements : Vec < PyObjectRef > ) -> Self {
26
34
PyList {
Original file line number Diff line number Diff line change 3
3
*/
4
4
5
5
use std:: cell:: { Cell , RefCell } ;
6
- use std:: collections:: hash_map:: DefaultHasher ;
7
- use std:: collections :: HashMap ;
6
+ use std:: collections:: { hash_map:: DefaultHasher , HashMap } ;
7
+ use std:: fmt ;
8
8
use std:: hash:: { Hash , Hasher } ;
9
9
10
10
use super :: objbool;
@@ -17,11 +17,18 @@ use crate::pyobject::{
17
17
} ;
18
18
use crate :: vm:: { ReprGuard , VirtualMachine } ;
19
19
20
- #[ derive( Debug , Default ) ]
20
+ #[ derive( Default ) ]
21
21
pub struct PySet {
22
22
elements : RefCell < HashMap < u64 , PyObjectRef > > ,
23
23
}
24
24
25
+ impl fmt:: Debug for PySet {
26
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
27
+ // TODO: implement more detailed, non-recursive Debug formatter
28
+ f. write_str ( "set" )
29
+ }
30
+ }
31
+
25
32
impl PyValue for PySet {
26
33
fn required_type ( ctx : & PyContext ) -> PyObjectRef {
27
34
ctx. set_type ( )
Original file line number Diff line number Diff line change 1
1
use std:: cell:: { Cell , RefCell } ;
2
+ use std:: fmt;
2
3
use std:: hash:: { Hash , Hasher } ;
3
4
4
5
use crate :: pyobject:: {
@@ -15,13 +16,20 @@ use super::objsequence::{
15
16
use super :: objstr;
16
17
use super :: objtype;
17
18
18
- #[ derive( Debug , Default ) ]
19
+ #[ derive( Default ) ]
19
20
pub struct PyTuple {
20
21
// TODO: shouldn't be public
21
22
// TODO: tuples are immutable, remove this RefCell
22
23
pub elements : RefCell < Vec < PyObjectRef > > ,
23
24
}
24
25
26
+ impl fmt:: Debug for PyTuple {
27
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
28
+ // TODO: implement more informational, non-recursive Debug formatter
29
+ f. write_str ( "tuple" )
30
+ }
31
+ }
32
+
25
33
impl From < Vec < PyObjectRef > > for PyTuple {
26
34
fn from ( elements : Vec < PyObjectRef > ) -> Self {
27
35
PyTuple {
You can’t perform that action at this time.
0 commit comments