File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -247,7 +247,7 @@ def _OneLineResult(result):
247
247
248
248
try :
249
249
return json .dumps (result )
250
- except TypeError :
250
+ except ( TypeError , ValueError ) :
251
251
return str (result ).replace ('\n ' , ' ' )
252
252
253
253
Original file line number Diff line number Diff line change @@ -33,6 +33,12 @@ def testOneLineResult(self):
33
33
self .assertEqual (core ._OneLineResult ({}), '{}' ) # pylint: disable=protected-access
34
34
self .assertEqual (core ._OneLineResult ({'x' : 'y' }), '{"x": "y"}' ) # pylint: disable=protected-access
35
35
36
+
37
+ def testOneLineResultCircularRef (self ):
38
+ circular_reference = tc .CircularReference ()
39
+ self .assertEqual (core ._OneLineResult (circular_reference .create ()), # pylint: disable=protected-access
40
+ "{'y': {...}}" )
41
+
36
42
@mock .patch ('fire.interact.Embed' )
37
43
def testInteractiveMode (self , mock_embed ):
38
44
core .Fire (tc .TypedProperties , 'alpha' )
Original file line number Diff line number Diff line change @@ -206,3 +206,11 @@ def totally_empty(self):
206
206
207
207
def nothing_printable (self ):
208
208
return {'__do_not_print_me' : 1 }
209
+
210
+
211
+ class CircularReference (object ):
212
+
213
+ def create (self ):
214
+ x = {}
215
+ x ['y' ] = x
216
+ return x
You can’t perform that action at this time.
0 commit comments