##// END OF EJS Templates
check-code: add a check for the next() builtin, which was new in 2.6
Augie Fackler -
r19501:725507cd stable
parent child Browse files
Show More
@@ -173,6 +173,8 b' pypats = ['
173 (r'^\s+(\w|\.)+=\w[^,()\n]*$', "missing whitespace in assignment"),
173 (r'^\s+(\w|\.)+=\w[^,()\n]*$', "missing whitespace in assignment"),
174 (r'(\s+)try:\n((?:\n|\1\s.*\n)+?)\1except.*?:\n'
174 (r'(\s+)try:\n((?:\n|\1\s.*\n)+?)\1except.*?:\n'
175 r'((?:\n|\1\s.*\n)+?)\1finally:', 'no try/except/finally in Python 2.4'),
175 r'((?:\n|\1\s.*\n)+?)\1finally:', 'no try/except/finally in Python 2.4'),
176 (r'(?<!def)(\s+|^|\()next\(.+\)',
177 'no next(foo) in Python 2.4 and 2.5, use foo.next() instead'),
176 (r'(\s+)try:\n((?:\n|\1\s.*\n)*?)\1\s*yield\b.*?'
178 (r'(\s+)try:\n((?:\n|\1\s.*\n)*?)\1\s*yield\b.*?'
177 r'((?:\n|\1\s.*\n)+?)\1finally:',
179 r'((?:\n|\1\s.*\n)+?)\1finally:',
178 'no yield inside try/finally in Python 2.4'),
180 'no yield inside try/finally in Python 2.4'),
@@ -22,6 +22,13 b''
22 > if any():
22 > if any():
23 > x = all()
23 > x = all()
24 > y = format(x)
24 > y = format(x)
25 > # next(generator) is new in 2.6
26 > z = next(x)
27 > # but generator.next() is okay
28 > x.next()
29 > # and we can make our own next
30 > def next(stuff):
31 > pass
25 >
32 >
26 > # Do not complain about our own definition
33 > # Do not complain about our own definition
27 > def any(x):
34 > def any(x):
@@ -94,13 +101,16 b''
94 ./non-py24.py:4:
101 ./non-py24.py:4:
95 > y = format(x)
102 > y = format(x)
96 any/all/format not available in Python 2.4
103 any/all/format not available in Python 2.4
97 ./non-py24.py:11:
104 ./non-py24.py:6:
105 > z = next(x)
106 no next(foo) in Python 2.4 and 2.5, use foo.next() instead
107 ./non-py24.py:18:
98 > try:
108 > try:
99 no try/except/finally in Python 2.4
109 no try/except/finally in Python 2.4
100 ./non-py24.py:28:
110 ./non-py24.py:35:
101 > try:
111 > try:
102 no yield inside try/finally in Python 2.4
112 no yield inside try/finally in Python 2.4
103 ./non-py24.py:33:
113 ./non-py24.py:40:
104 > try:
114 > try:
105 no yield inside try/finally in Python 2.4
115 no yield inside try/finally in Python 2.4
106 ./classstyle.py:4:
116 ./classstyle.py:4:
General Comments 0
You need to be logged in to leave comments. Login now