Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
74284b96
Kaydet (Commit)
74284b96
authored
Eki 08, 2006
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #1542451: fix crash with continue in nested try/finally
(backport from rev. 51439)
üst
2c8851e6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
4 deletions
+96
-4
test_syntax.py
Lib/test/test_syntax.py
+84
-0
NEWS
Misc/NEWS
+2
-0
compile.c
Python/compile.c
+10
-4
No files found.
Lib/test/test_syntax.py
Dosyayı görüntüle @
74284b96
...
...
@@ -235,6 +235,90 @@ SyntaxError: assignment to None (<doctest test.test_syntax[32]>, line 1)
>>> f() += 1
Traceback (most recent call last):
SyntaxError: illegal expression for augmented assignment (<doctest test.test_syntax[33]>, line 1)
Test continue in finally in weird combinations.
continue in for loop under finally shouuld be ok.
>>> def test():
... try:
... pass
... finally:
... for abc in range(10):
... continue
... print abc
>>> test()
9
Start simple, a continue in a finally should not be allowed.
>>> def test():
... for abc in range(10):
... try:
... pass
... finally:
... continue
...
Traceback (most recent call last):
...
SyntaxError: 'continue' not supported inside 'finally' clause (<doctest test.test_syntax[36]>, line 6)
This is essentially a continue in a finally which should not be allowed.
>>> def test():
... for abc in range(10):
... try:
... pass
... finally:
... try:
... continue
... except:
... pass
Traceback (most recent call last):
...
SyntaxError: 'continue' not supported inside 'finally' clause (<doctest test.test_syntax[37]>, line 7)
>>> def foo():
... try:
... pass
... finally:
... continue
Traceback (most recent call last):
...
SyntaxError: 'continue' not supported inside 'finally' clause (<doctest test.test_syntax[38]>, line 5)
>>> def foo():
... for a in ():
... try: pass
... finally: continue
Traceback (most recent call last):
...
SyntaxError: 'continue' not supported inside 'finally' clause (<doctest test.test_syntax[39]>, line 4)
>>> def foo():
... for a in ():
... try: pass
... finally:
... try:
... continue
... finally: pass
Traceback (most recent call last):
...
SyntaxError: 'continue' not supported inside 'finally' clause (<doctest test.test_syntax[40]>, line 6)
>>> def foo():
... for a in ():
... try: pass
... finally:
... try:
... pass
... except:
... continue
Traceback (most recent call last):
...
SyntaxError: 'continue' not supported inside 'finally' clause (<doctest test.test_syntax[41]>, line 8)
"""
import
re
...
...
Misc/NEWS
Dosyayı görüntüle @
74284b96
...
...
@@ -12,6 +12,8 @@ What's New in Python 2.5.1c1?
Core and builtins
-----------------
- Patch #1542451: disallow continue anywhere under a finally.
- list.pop(x) accepts any object x following the __index__ protocol.
- Fix some leftovers from the conversion from int to Py_ssize_t
...
...
Python/compile.c
Dosyayı görüntüle @
74284b96
...
...
@@ -2288,6 +2288,8 @@ static int
compiler_continue
(
struct
compiler
*
c
)
{
static
const
char
LOOP_ERROR_MSG
[]
=
"'continue' not properly in loop"
;
static
const
char
IN_FINALLY_ERROR_MSG
[]
=
"'continue' not supported inside 'finally' clause"
;
int
i
;
if
(
!
c
->
u
->
u_nfblocks
)
...
...
@@ -2299,15 +2301,19 @@ compiler_continue(struct compiler *c)
break
;
case
EXCEPT
:
case
FINALLY_TRY
:
while
(
--
i
>=
0
&&
c
->
u
->
u_fblock
[
i
].
fb_type
!=
LOOP
)
;
while
(
--
i
>=
0
&&
c
->
u
->
u_fblock
[
i
].
fb_type
!=
LOOP
)
{
/* Prevent try: ... finally:
try: continue ... or
try: ... except: continue */
if
(
c
->
u
->
u_fblock
[
i
].
fb_type
==
FINALLY_END
)
return
compiler_error
(
c
,
IN_FINALLY_ERROR_MSG
);
}
if
(
i
==
-
1
)
return
compiler_error
(
c
,
LOOP_ERROR_MSG
);
ADDOP_JABS
(
c
,
CONTINUE_LOOP
,
c
->
u
->
u_fblock
[
i
].
fb_block
);
break
;
case
FINALLY_END
:
return
compiler_error
(
c
,
"'continue' not supported inside 'finally' clause"
);
return
compiler_error
(
c
,
IN_FINALLY_ERROR_MSG
);
}
return
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment