File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -412,6 +412,8 @@ def stdoutEncode(value):
412412 Returns textual representation of a given value safe for writing to stdout
413413 >>> stdoutEncode(b"foobar")
414414 'foobar'
415+ >>> stdoutEncode({"url": "http://example.com/foo", "data": "id=1"}) == {"url": "http://example.com/foo", "data": "id=1"}
416+ True
415417 """
416418
417419 if value is None :
@@ -437,7 +439,11 @@ def stdoutEncode(value):
437439 if isinstance (value , (bytes , bytearray )):
438440 value = getUnicode (value , encoding )
439441 elif not isinstance (value , str ):
440- value = str (value )
442+ # Non-string values (e.g. dicts passed through the REST API path,
443+ # where the overridden sys.stdout.write JSON-encodes the value)
444+ # must be returned unchanged — stringifying them via str() yields
445+ # Python repr() output that the API consumer cannot parse.
446+ return value
441447
442448 try :
443449 retVal = value .encode (encoding , errors = "replace" ).decode (encoding , errors = "replace" )
You can’t perform that action at this time.
0 commit comments