Commit c72cd071 authored by Arnaud Fontaine's avatar Arnaud Fontaine

py3: Add functions to convert bytes/str/unicode (from slapos.util).

Stricter than six.ensure_{text,str}().
parent 7e551eb7
......@@ -550,6 +550,19 @@ def checkPythonSourceCode(source_code_str, portal_type=None):
#LOG('Utils', INFO, 'Checking time (pylint): %.2f' % (time.time() - started))
return message_list
# Used for Python 2-3 compatibility
if str is bytes:
bytes2str = str2bytes = lambda s: s
def unicode2str(s):
return s.encode('utf-8')
else:
def bytes2str(s):
return s.decode()
def str2bytes(s):
return s.encode()
def unicode2str(s):
return s
#####################################################
# Globals initialization
#####################################################
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment