From 074e1cdb5689ecd269336188feb26e58c58ab4d9 Mon Sep 17 00:00:00 2001
From: Arnaud Fontaine <arnaud.fontaine@nexedi.com>
Date: Mon, 24 Feb 2014 20:47:51 +0900
Subject: [PATCH] ZODB Components: When checking source, improve message when a
 SyntaxError is raised through compile().

---
 product/ERP5Type/mixin/component.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/product/ERP5Type/mixin/component.py b/product/ERP5Type/mixin/component.py
index d862fa767c..da82dd41cb 100644
--- a/product/ERP5Type/mixin/component.py
+++ b/product/ERP5Type/mixin/component.py
@@ -297,6 +297,11 @@ class ComponentMixin(PropertyRecordableMixin, Base):
         compile(source_code, '<string>', 'exec')
         return [], []
       except BaseException, error:
+        if isinstance(error, SyntaxError):
+          error = '%4d, %4d: %s' % (error.lineno,
+                                    error.offset,
+                                    error.message)
+
         return ['F: %s' % error], []
 
     import cStringIO
-- 
2.30.9