diff --git a/IM/REST.py b/IM/REST.py index 1a6720578..742b1fac2 100644 --- a/IM/REST.py +++ b/IM/REST.py @@ -284,7 +284,7 @@ def format_output(res, default_type="text/plain", field_name=None, list_field_na if isinstance(res, list): info = "\n".join(res) else: - info = str(res) + info = "%s" % res content_type = default_type break @@ -299,7 +299,7 @@ def format_output(res, default_type="text/plain", field_name=None, list_field_na if isinstance(res, list): info = "\n".join(res) else: - info = str(res) + info = "%s" % res bottle.response.content_type = default_type return info diff --git a/test/unit/REST.py b/test/unit/REST.py index 0520aa01a..a6f8ab1db 100755 --- a/test/unit/REST.py +++ b/test/unit/REST.py @@ -778,6 +778,9 @@ def test_format_output(self, get_media_type): info = format_output(["1", "2"]) self.assertEqual(info, '1\n2') + info = format_output(u'contmsg\xe1', field_name="contmsg", default_type="text/plain") + self.assertEqual(info, u'contmsg\xe1') + get_media_type.return_value = ["application/zip"] info = format_output(["1", "2"]) self.assertEqual(info, 'Unsupported Accept Media Types: application/zip')