@@ -76,12 +76,19 @@ impl<'a, T> Iterator for Iter<'a, T> {
76
76
}
77
77
}
78
78
79
- #[ derive( Debug , Clone ) ]
79
+ #[ derive( Clone ) ]
80
80
pub struct Scope {
81
81
locals : RcList < PyObjectRef > ,
82
82
pub globals : PyObjectRef ,
83
83
}
84
84
85
+ impl fmt:: Debug for Scope {
86
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
87
+ // TODO: have a more informative Debug impl that DOESN'T recurse and cause a stack overflow
88
+ f. write_str ( "Scope" )
89
+ }
90
+ }
91
+
85
92
impl Scope {
86
93
pub fn new ( locals : Option < PyObjectRef > , globals : PyObjectRef ) -> Scope {
87
94
let locals = match locals {
@@ -99,10 +106,7 @@ impl Scope {
99
106
}
100
107
101
108
pub fn get_only_locals ( & self ) -> Option < PyObjectRef > {
102
- match self . locals . iter ( ) . next ( ) {
103
- Some ( dict) => Some ( dict. clone ( ) ) ,
104
- None => None ,
105
- }
109
+ self . locals . iter ( ) . next ( ) . cloned ( )
106
110
}
107
111
108
112
pub fn child_scope_with_locals ( & self , locals : PyObjectRef ) -> Scope {
@@ -1212,21 +1216,18 @@ impl fmt::Debug for Frame {
1212
1216
. borrow ( )
1213
1217
. iter ( )
1214
1218
. map ( |elem| format ! ( "\n > {:?}" , elem) )
1215
- . collect :: < Vec < _ > > ( )
1216
- . join ( "" ) ;
1219
+ . collect :: < String > ( ) ;
1217
1220
let block_str = self
1218
1221
. blocks
1219
1222
. borrow ( )
1220
1223
. iter ( )
1221
1224
. map ( |elem| format ! ( "\n > {:?}" , elem) )
1222
- . collect :: < Vec < _ > > ( )
1223
- . join ( "" ) ;
1225
+ . collect :: < String > ( ) ;
1224
1226
let local_str = match self . scope . get_locals ( ) . payload :: < PyDict > ( ) {
1225
1227
Some ( dict) => objdict:: get_key_value_pairs_from_content ( & dict. entries . borrow ( ) )
1226
1228
. iter ( )
1227
1229
. map ( |elem| format ! ( "\n {:?} = {:?}" , elem. 0 , elem. 1 ) )
1228
- . collect :: < Vec < _ > > ( )
1229
- . join ( "" ) ,
1230
+ . collect :: < String > ( ) ,
1230
1231
None => panic ! ( "locals unexpectedly not wrapping a dict!" , ) ,
1231
1232
} ;
1232
1233
write ! (
0 commit comments