1) Forbid string exceptions globally (issue 715 related)
 2) Forbid generic exceptions (i.e. 'raise Exception(...)')
---
 sympy/utilities/tests/test_code_quality.py |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/sympy/utilities/tests/test_code_quality.py 
b/sympy/utilities/tests/test_code_quality.py
index b2f2e91..0c62905 100644
--- a/sympy/utilities/tests/test_code_quality.py
+++ b/sympy/utilities/tests/test_code_quality.py
@@ -18,6 +18,8 @@ message_space = "File contains trailing whitespace: %s, line 
%s."
 message_implicit = "File contains an implicit import: %s, line %s."
 message_tabs = "File contains tabs instead of spaces: %s, line %s."
 message_carriage = "File contains carriage returns at end of line: %s, line %s"
+message_str_raise = "File contains string exception: %s, line %s"
+message_gen_raise = "File contains generic exception: %s, line %s"
 
 def get_whitespace(s):
     """Returns all whitespace at the beginning of the line."""
@@ -31,6 +33,8 @@ def check_directory_tree(base_path):
     Checks all files in the directory tree (with base_path as starting point)
     for bad coding style.
     """
+    strRaise = re.compile(r'raise(\s+(\'|\")|\s*(\(\s*)+(\'|\"))')
+    genRaise = re.compile(r'raise(\s+Exception|\s*(\(\s*)+Exception)')
     for root, dirs, files in walk(base_path):
         for fname in glob(join(root, "*.py")):
             if filter(lambda ex: ex in fname, EXCLUDE):
@@ -46,6 +50,10 @@ def check_directory_tree(base_path):
                     w = get_whitespace(line)
                     if w.expandtabs() != w:
                         assert False, message_tabs % (fname, idx+1)
+                    if strRaise.search(line):
+                        assert False, message_str_raise % (fname, idx+1)
+                    if genRaise.search(line):
+                        assert False, message_gen_raise % (fname, idx+1)
             finally:
                 file.close()
 
-- 
1.5.6.5


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy-patches" group.
To post to this group, send email to sympy-patches@googlegroups.com
To unsubscribe from this group, send email to 
sympy-patches+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sympy-patches?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to