summaryrefslogtreecommitdiff
path: root/odoo/tools
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2017-04-11 12:44:29 +0200
committerXavier Morel <xmo@odoo.com>2017-04-11 14:53:29 +0200
commit3979f6802eeea275f949d28ddf4c18f84fc0f5aa (patch)
tree0c67d60c80b2ece2e452837c187a79e9444334d8 /odoo/tools
parentca74b5e1c8a48bcdeb396625ec0d8028a5a9d5f1 (diff)
[#8530] convert exception handlers to except..as syntax
Futurize fixers: * lib2to3.fixes.fix_except
Diffstat (limited to 'odoo/tools')
-rw-r--r--odoo/tools/convert.py2
-rw-r--r--odoo/tools/mail.py2
-rw-r--r--odoo/tools/safe_eval.py4
-rw-r--r--odoo/tools/test_reports.py2
-rw-r--r--odoo/tools/translate.py2
-rw-r--r--odoo/tools/xml_utils.py2
-rw-r--r--odoo/tools/yaml_import.py12
7 files changed, 13 insertions, 13 deletions
diff --git a/odoo/tools/convert.py b/odoo/tools/convert.py
index 1301e035241..c7faab244d3 100644
--- a/odoo/tools/convert.py
+++ b/odoo/tools/convert.py
@@ -781,7 +781,7 @@ form: module.record_id""" % (xml_id,)
elif rec.tag in self._tags:
try:
self._tags[rec.tag](rec, de, mode=mode)
- except Exception, e:
+ except Exception as e:
self.cr.rollback()
exc_info = sys.exc_info()
raise ParseError, (ustr(e), etree.tostring(rec).rstrip(), rec.getroottree().docinfo.URL, rec.sourceline), exc_info[2]
diff --git a/odoo/tools/mail.py b/odoo/tools/mail.py
index e1a4eeb9c54..490006082d5 100644
--- a/odoo/tools/mail.py
+++ b/odoo/tools/mail.py
@@ -233,7 +233,7 @@ def html_sanitize(src, silent=True, sanitize_tags=True, sanitize_attributes=Fals
cleaned = cleaned.replace('%&gt;', '%>')
# html considerations so real html content match database value
cleaned.replace(u'\xa0', '&nbsp;')
- except etree.ParserError, e:
+ except etree.ParserError as e:
if 'empty' in str(e):
return ""
if not silent:
diff --git a/odoo/tools/safe_eval.py b/odoo/tools/safe_eval.py
index 4d8e5b63d9f..14020378c21 100644
--- a/odoo/tools/safe_eval.py
+++ b/odoo/tools/safe_eval.py
@@ -156,7 +156,7 @@ def test_expr(expr, allowed_codes, mode="eval"):
code_obj = compile(expr, "", mode)
except (SyntaxError, TypeError, ValueError):
raise
- except Exception, e:
+ except Exception as e:
import sys
exc_info = sys.exc_info()
raise ValueError, '"%s" while compiling\n%r' % (ustr(e), expr), exc_info[2]
@@ -319,7 +319,7 @@ def safe_eval(expr, globals_dict=None, locals_dict=None, mode="eval", nocopy=Fal
raise
except odoo.exceptions.MissingError:
raise
- except Exception, e:
+ except Exception as e:
import sys
exc_info = sys.exc_info()
raise ValueError, '%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr), exc_info[2]
diff --git a/odoo/tools/test_reports.py b/odoo/tools/test_reports.py
index 962f84b2ed7..ef09862bc01 100644
--- a/odoo/tools/test_reports.py
+++ b/odoo/tools/test_reports.py
@@ -218,7 +218,7 @@ def try_report_action(cr, uid, action_id, active_model=None, active_ids=None,
'type': button.getAttribute('type'),
'weight': button_weight,
})
- except Exception, e:
+ except Exception as e:
_logger.warning("Cannot resolve the view arch and locate the buttons!", exc_info=True)
raise AssertionError(e.args[0])
diff --git a/odoo/tools/translate.py b/odoo/tools/translate.py
index c947ae5e75d..b33b356a2f9 100644
--- a/odoo/tools/translate.py
+++ b/odoo/tools/translate.py
@@ -846,7 +846,7 @@ def trans_generate(lang, modules, cr):
if model=='ir.model.fields':
try:
field_name = encode(record.name)
- except AttributeError, exc:
+ except AttributeError as exc:
_logger.error("name error in %s: %s", xml_name, str(exc))
continue
field_model = env.get(record.model)
diff --git a/odoo/tools/xml_utils.py b/odoo/tools/xml_utils.py
index d179559db75..df4c5669644 100644
--- a/odoo/tools/xml_utils.py
+++ b/odoo/tools/xml_utils.py
@@ -10,7 +10,7 @@ def check_with_xsd(tree_or_str, xsd_path):
xsd_schema = etree.XMLSchema(xml_schema_doc)
try:
xsd_schema.assertValid(tree_or_str)
- except etree.DocumentInvalid, xml_errors:
+ except etree.DocumentInvalid as xml_errors:
#import UserError only here to avoid circular import statements with tools.func being imported in exceptions.py
from odoo.exceptions import UserError
raise UserError('\n'.join([e.message for e in xml_errors.error_log]))
diff --git a/odoo/tools/yaml_import.py b/odoo/tools/yaml_import.py
index 8e9e1342a70..cefc3667a9e 100644
--- a/odoo/tools/yaml_import.py
+++ b/odoo/tools/yaml_import.py
@@ -227,7 +227,7 @@ class YamlInterpreter(object):
for test in expressions:
try:
success = unsafe_eval(test, self.eval_context, RecordDictWrapper(record))
- except Exception, e:
+ except Exception as e:
_logger.debug('Exception during evaluation of !assert block in yaml_file %s.', self.filename, exc_info=True)
raise YamlImportAbortion(e)
if not success:
@@ -240,12 +240,12 @@ class YamlInterpreter(object):
rmsg = ''
try:
lmsg = unsafe_eval(left, self.eval_context, RecordDictWrapper(record))
- except Exception, e:
+ except Exception as e:
lmsg = '<exc>'
try:
rmsg = unsafe_eval(right, self.eval_context, RecordDictWrapper(record))
- except Exception, e:
+ except Exception as e:
rmsg = '<exc>'
msg += 'values: ! %s %s %s'
@@ -605,11 +605,11 @@ class YamlInterpreter(object):
try:
code_obj = compile(statements, self.filename, 'exec')
unsafe_eval(code_obj, {'ref': self.get_id}, code_context)
- except AssertionError, e:
+ except AssertionError as e:
self._log_assert_failure('AssertionError in Python code %s (line %d): %s',
python.name, python.first_line, e)
return
- except Exception, e:
+ except Exception as e:
_logger.debug('Exception during evaluation of !python block in yaml_file %s.', self.filename, exc_info=True)
raise
else:
@@ -847,7 +847,7 @@ class YamlInterpreter(object):
is_preceded_by_comment = self._log_node(node, is_preceded_by_comment)
try:
self._process_node(node)
- except Exception, e:
+ except Exception as e:
_logger.exception(e)
raise