From d02f5e9d2909790dcc2c1020c7975872d210f1bd Mon Sep 17 00:00:00 2001 From: henrietta <piotr.maslanka@henrietta.com.pl> Date: Mon, 5 Aug 2013 14:29:57 +0200 Subject: [PATCH] more robust instrumentation_as_json 1) If input data contains heavy Unicode, export() will not fail. 2) Exported string will be reliably a str, UTF-8 encoded --- contrib/instrumentation_as_json.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contrib/instrumentation_as_json.py b/contrib/instrumentation_as_json.py index 67ef12bb..0dd888b6 100644 --- a/contrib/instrumentation_as_json.py +++ b/contrib/instrumentation_as_json.py @@ -25,5 +25,7 @@ def asval(cc): return f def export(insmgr): - """Constructs a JSON string based on data from given insmgr""" - return json.dumps(asval(insmgr)) \ No newline at end of file + """Constructs a JSON string based on data from given insmgr. + @type insmgr: satella.instrumentation.CounterCollection + @return: UTF-8 encoded JSON""" + return json.dumps(asval(insmgr), ensure_ascii=False).encode('utf8') \ No newline at end of file -- GitLab