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):
247247
248248 try :
249249 return json .dumps (result )
250- except TypeError :
250+ except ( TypeError , ValueError ) :
251251 return str (result ).replace ('\n ' , ' ' )
252252
253253
Original file line number Diff line number Diff line change @@ -33,6 +33,12 @@ def testOneLineResult(self):
3333 self .assertEqual (core ._OneLineResult ({}), '{}' ) # pylint: disable=protected-access
3434 self .assertEqual (core ._OneLineResult ({'x' : 'y' }), '{"x": "y"}' ) # pylint: disable=protected-access
3535
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+
3642 @mock .patch ('fire.interact.Embed' )
3743 def testInteractiveMode (self , mock_embed ):
3844 core .Fire (tc .TypedProperties , 'alpha' )
Original file line number Diff line number Diff line change @@ -206,3 +206,11 @@ def totally_empty(self):
206206
207207 def nothing_printable (self ):
208208 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