Commit cdb2c0b7 authored by Jérome Perrin's avatar Jérome Perrin Committed by Arnaud Fontaine

core: PythonCodeUtils python3

parent a96df1c3
from six import string_types as basestring
import re import re
import six
import json import json
import sys import sys
from zExceptions import ExceptionFormatter from zExceptions import ExceptionFormatter
...@@ -15,7 +15,7 @@ def checkPythonSourceCodeAsJSON(self, data, REQUEST=None): ...@@ -15,7 +15,7 @@ def checkPythonSourceCodeAsJSON(self, data, REQUEST=None):
""" """
# XXX data is encoded as json, because jQuery serialize lists as [] # XXX data is encoded as json, because jQuery serialize lists as []
if isinstance(data, basestring): if isinstance(data, six.string_types):
data = json.loads(data) data = json.loads(data)
# data contains the code, the bound names and the script params. From this # data contains the code, the bound names and the script params. From this
...@@ -49,8 +49,10 @@ def checkPythonSourceCodeAsJSON(self, data, REQUEST=None): ...@@ -49,8 +49,10 @@ def checkPythonSourceCodeAsJSON(self, data, REQUEST=None):
else: else:
body = data['code'] body = data['code']
if six.PY2:
body = body.encode('utf8')
try: try:
message_list = checkPythonSourceCode(body.encode('utf8'), data.get('portal_type')) message_list = checkPythonSourceCode(body, data.get('portal_type'))
except Exception: except Exception:
message_list = [{ message_list = [{
'type': 'E', 'type': 'E',
......
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