Commit a6be8770 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Arnaud Fontaine

py2/py3: add str2unicode() utility function, that does nothing in Python 3.

parent c4d41710
...@@ -569,6 +569,8 @@ def checkPythonSourceCode(source_code_str, portal_type=None): ...@@ -569,6 +569,8 @@ def checkPythonSourceCode(source_code_str, portal_type=None):
if str is bytes: if str is bytes:
bytes2str = str2bytes = lambda s: s bytes2str = str2bytes = lambda s: s
def str2unicode(s):
return s.decode('utf-8')
def unicode2str(s): def unicode2str(s):
return s.encode('utf-8') return s.encode('utf-8')
else: else:
...@@ -576,6 +578,8 @@ else: ...@@ -576,6 +578,8 @@ else:
return s.decode() return s.decode()
def str2bytes(s): def str2bytes(s):
return s.encode() return s.encode()
def str2unicode(s):
return s
def unicode2str(s): def unicode2str(s):
return s return s
......
...@@ -190,7 +190,7 @@ ModuleSecurityInfo('Products.ERP5Type.Utils').declarePublic( ...@@ -190,7 +190,7 @@ ModuleSecurityInfo('Products.ERP5Type.Utils').declarePublic(
'int2letter', 'getMessageIdWithContext', 'getTranslationStringWithContext', 'int2letter', 'getMessageIdWithContext', 'getTranslationStringWithContext',
'Email_parseAddressHeader', 'guessEncodingFromText', 'Email_parseAddressHeader', 'guessEncodingFromText',
'isValidTALESExpression', 'isValidTALESExpression',
'ensure_list', 'bytes2str', 'str2bytes', 'unicode2str', 'ensure_list', 'bytes2str', 'str2bytes', 'str2unicode', 'unicode2str',
) )
allow_module('Products.ERP5Type.Message') allow_module('Products.ERP5Type.Message')
......
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