File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,16 @@ RuntimeError
2727(not used any more?)
2828spam
2929SyntaxError
30+ 'continue' not supported inside 'try' clause
31+ ok
32+ 'continue' not supported inside 'try' clause
33+ ok
34+ 'continue' not supported inside 'try' clause
35+ ok
36+ 'continue' not properly in loop
37+ ok
38+ 'continue' not properly in loop
39+ ok
3040spam
3141IndentationError
3242spam
Original file line number Diff line number Diff line change @@ -86,6 +86,55 @@ def r(thing):
8686try : exec '/\n '
8787except SyntaxError : pass
8888
89+ # make sure the right exception message is raised for each of these
90+ # code fragments:
91+
92+ def ckmsg (src , msg ):
93+ try :
94+ compile (src , '<fragment>' , 'exec' )
95+ except SyntaxError , e :
96+ print e .msg
97+ if e .msg == msg :
98+ print "ok"
99+ else :
100+ print "expected:" , msg
101+ else :
102+ print "failed to get expected SyntaxError"
103+
104+ s = '''\
105+ while 1:
106+ try:
107+ continue
108+ except:
109+ pass
110+ '''
111+ ckmsg (s , "'continue' not supported inside 'try' clause" )
112+ s = '''\
113+ while 1:
114+ try:
115+ continue
116+ finally:
117+ pass
118+ '''
119+ ckmsg (s , "'continue' not supported inside 'try' clause" )
120+ s = '''\
121+ while 1:
122+ try:
123+ if 1:
124+ continue
125+ finally:
126+ pass
127+ '''
128+ ckmsg (s , "'continue' not supported inside 'try' clause" )
129+ s = '''\
130+ try:
131+ continue
132+ except:
133+ pass
134+ '''
135+ ckmsg (s , "'continue' not properly in loop" )
136+ ckmsg ("continue\n " , "'continue' not properly in loop" )
137+
89138r (IndentationError )
90139
91140r (TabError )
You can’t perform that action at this time.
0 commit comments