@@ -187,6 +187,45 @@ def check(src, lineno, offset):
187187 check ('def spam():\n print(1)\n print(2)' , 3 , 10 )
188188 check ('Python = "Python" +' , 1 , 20 )
189189 check ('Python = "\u1e54 \xfd \u0163 \u0125 \xf2 \xf1 " +' , 1 , 20 )
190+ check ('x = "a' , 1 , 7 )
191+ check ('lambda x: x = 2' , 1 , 1 )
192+
193+ # Errors thrown by compile.c
194+ check ('class foo:return 1' , 1 , 11 )
195+ check ('def f():\n continue' , 2 , 3 )
196+ check ('def f():\n break' , 2 , 3 )
197+ check ('try:\n pass\n except:\n pass\n except ValueError:\n pass' , 2 , 3 )
198+
199+ # Errors thrown by tokenizer.c
200+ check ('(0x+1)' , 1 , 3 )
201+ check ('x = 0xI' , 1 , 6 )
202+ check ('0010 + 2' , 1 , 4 )
203+ check ('x = 32e-+4' , 1 , 8 )
204+ check ('x = 0o9' , 1 , 6 )
205+
206+ # Errors thrown by symtable.c
207+ check ('x = [(yield i) for i in range(3)]' , 1 , 6 )
208+ check ('def f():\n from _ import *' , 1 , 1 )
209+ check ('def f(x, x):\n pass' , 1 , 1 )
210+ check ('def f(x):\n nonlocal x' , 2 , 3 )
211+ check ('def f(x):\n x = 1\n global x' , 3 , 3 )
212+ check ('nonlocal x' , 1 , 1 )
213+ check ('def f():\n global x\n nonlocal x' , 2 , 3 )
214+
215+ # Errors thrown by ast.c
216+ check ('for 1 in []: pass' , 1 , 5 )
217+ check ('def f(*):\n pass' , 1 , 7 )
218+ check ('[*x for x in xs]' , 1 , 2 )
219+ check ('def f():\n x, y: int' , 2 , 3 )
220+ check ('(yield i) = 2' , 1 , 1 )
221+ check ('foo(x for x in range(10), 100)' , 1 , 5 )
222+ check ('foo(1=2)' , 1 , 5 )
223+
224+ # Errors thrown by future.c
225+ check ('from __future__ import doesnt_exist' , 1 , 1 )
226+ check ('from __future__ import braces' , 1 , 1 )
227+ check ('x=1\n from __future__ import division' , 2 , 1 )
228+
190229
191230 @cpython_only
192231 def testSettingException (self ):
0 commit comments