From 0bdc3011ce40cbbd23dd62aff56a150d5b921fb9 Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Mon, 1 Jul 2013 17:02:19 +1000 Subject: [PATCH] fixes StringIO unicode handling in python 2.7 --- contrib/collectd_network.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/contrib/collectd_network.py b/contrib/collectd_network.py index 9af0fb00..9c1e9fb1 100644 --- a/contrib/collectd_network.py +++ b/contrib/collectd_network.py @@ -17,10 +17,15 @@ Collectd network protocol implementation. """ import socket,struct,sys -try: - from io import StringIO -except ImportError: - from cStringIO import StringIO +import platform +if platform.python_version() < '2.8.0': + # Python 2.7 and below io.StringIO does not like unicode + from StringIO import StringIO +else: + try: + from io import StringIO + except ImportError: + from cStringIO import StringIO from datetime import datetime from copy import deepcopy -- 2.30.2