提交 3a4bf77b 编写于 作者: N nicolargo

Correct another fucking issue about Python 3 bytes string to regular string (issue #933)

上级 b2ea5104
......@@ -15,6 +15,7 @@ Enhancements and new features:
Bugs corrected:
* Glances RAID plugin Traceback (issue #927)
* Default AMP crashes when 'command' given (issue #933)
Version 2.7.1
=============
......
......@@ -28,12 +28,6 @@ import types
PY3 = sys.version_info[0] == 3
def to_ascii(s):
"""Convert the unicode 's' to a ASCII string
Usefull to remove accent (diacritics)"""
return unicodedata.normalize('NFKD', s).encode('ASCII', 'ignore')
if PY3:
import queue
from configparser import ConfigParser, NoOptionError, NoSectionError
......@@ -54,6 +48,11 @@ if PY3:
viewvalues = operator.methodcaller('values')
viewitems = operator.methodcaller('items')
def to_ascii(s):
"""Convert the bytes string to a ASCII string
Usefull to remove accent (diacritics)"""
return str(s, 'utf-8')
def listitems(d):
return list(d.items())
......@@ -104,6 +103,11 @@ else:
viewvalues = operator.methodcaller('viewvalues')
viewitems = operator.methodcaller('viewitems')
def to_ascii(s):
"""Convert the unicode 's' to a ASCII string
Usefull to remove accent (diacritics)"""
return unicodedata.normalize('NFKD', s).encode('ASCII', 'ignore')
def listitems(d):
return d.items()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册