comparison contrib/check-code.py @ 18180:c582a71457e5

check-code: disallow two-argument form of raise Using this old form makes any attempt to port to Python 3 harder, and the new syntax is supported in 2.4 already.
author Augie Fackler <raf@durin42.com>
date Tue, 01 Jan 2013 12:58:21 -0600
parents e440a2c0d944
children e1caaeb5a2ed
comparison
equal deleted inserted replaced
18179:f614543733b6 18180:c582a71457e5
183 (r'\s(\+=|-=|!=|<>|<=|>=|<<=|>>=|%=)\S', 183 (r'\s(\+=|-=|!=|<>|<=|>=|<<=|>>=|%=)\S',
184 "missing whitespace around operator"), 184 "missing whitespace around operator"),
185 (r'[^^+=*/!<>&| %-](\s=|=\s)[^= ]', 185 (r'[^^+=*/!<>&| %-](\s=|=\s)[^= ]',
186 "wrong whitespace around ="), 186 "wrong whitespace around ="),
187 (r'raise Exception', "don't raise generic exceptions"), 187 (r'raise Exception', "don't raise generic exceptions"),
188 (r'raise [^,(]+, (\([^\)]+\)|[^,\(\)]+)$',
189 "don't use old-style two-argument raise, use Exception(message)"),
188 (r' is\s+(not\s+)?["\'0-9-]', "object comparison with literal"), 190 (r' is\s+(not\s+)?["\'0-9-]', "object comparison with literal"),
189 (r' [=!]=\s+(True|False|None)', 191 (r' [=!]=\s+(True|False|None)',
190 "comparison with singleton, use 'is' or 'is not' instead"), 192 "comparison with singleton, use 'is' or 'is not' instead"),
191 (r'^\s*(while|if) [01]:', 193 (r'^\s*(while|if) [01]:',
192 "use True/False for constant Boolean expression"), 194 "use True/False for constant Boolean expression"),