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
397466df
Unverified
Kaydet (Commit)
397466df
authored
Mar 23, 2018
tarafından
Serhiy Storchaka
Kaydeden (comit)
GitHub
Mar 23, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-30953: Improve error messages and add tests for jumping (GH-6196)
into/out of an except block.
üst
702f8f36
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
8 deletions
+70
-8
test_sys_settrace.py
Lib/test/test_sys_settrace.py
+64
-6
frameobject.c
Objects/frameobject.c
+6
-2
No files found.
Lib/test/test_sys_settrace.py
Dosyayı görüntüle @
397466df
...
...
@@ -1201,8 +1201,16 @@ class JumpTestCase(unittest.TestCase):
output
.
append
(
7
)
output
.
append
(
8
)
@jump_test
(
3
,
6
,
[
2
,
5
,
6
],
(
ValueError
,
'finally'
))
@jump_test
(
1
,
5
,
[],
(
ValueError
,
"into a 'finally'"
))
def
test_no_jump_into_finally_block
(
output
):
output
.
append
(
1
)
try
:
output
.
append
(
3
)
finally
:
output
.
append
(
5
)
@jump_test
(
3
,
6
,
[
2
,
5
,
6
],
(
ValueError
,
"into a 'finally'"
))
def
test_no_jump_into_finally_block_from_try_block
(
output
):
try
:
output
.
append
(
2
)
output
.
append
(
3
)
...
...
@@ -1211,21 +1219,71 @@ class JumpTestCase(unittest.TestCase):
output
.
append
(
6
)
output
.
append
(
7
)
@jump_test
(
1
,
5
,
[],
(
ValueError
,
'finally'
))
def
test_no_jump_
into_finally_block_2
(
output
):
@jump_test
(
5
,
1
,
[
1
,
3
],
(
ValueError
,
"out of a 'finally'"
))
def
test_no_jump_
out_of_finally_block
(
output
):
output
.
append
(
1
)
try
:
output
.
append
(
3
)
finally
:
output
.
append
(
5
)
@jump_test
(
5
,
1
,
[
1
,
3
],
(
ValueError
,
'finally'
))
def
test_no_jump_
out_of_finally
_block
(
output
):
@jump_test
(
1
,
5
,
[],
(
ValueError
,
"into an 'except'"
))
def
test_no_jump_
into_bare_except
_block
(
output
):
output
.
append
(
1
)
try
:
output
.
append
(
3
)
finally
:
except
:
output
.
append
(
5
)
@jump_test
(
1
,
5
,
[],
(
ValueError
,
"into an 'except'"
))
def
test_no_jump_into_qualified_except_block
(
output
):
output
.
append
(
1
)
try
:
output
.
append
(
3
)
except
Exception
:
output
.
append
(
5
)
@jump_test
(
3
,
6
,
[
2
,
5
,
6
],
(
ValueError
,
"into an 'except'"
))
def
test_no_jump_into_bare_except_block_from_try_block
(
output
):
try
:
output
.
append
(
2
)
output
.
append
(
3
)
except
:
# executed if the jump is failed
output
.
append
(
5
)
output
.
append
(
6
)
raise
output
.
append
(
8
)
@jump_test
(
3
,
6
,
[
2
],
(
ValueError
,
"into an 'except'"
))
def
test_no_jump_into_qualified_except_block_from_try_block
(
output
):
try
:
output
.
append
(
2
)
output
.
append
(
3
)
except
ZeroDivisionError
:
output
.
append
(
5
)
output
.
append
(
6
)
raise
output
.
append
(
8
)
@jump_test
(
7
,
1
,
[
1
,
3
,
6
],
(
ValueError
,
"out of an 'except'"
))
def
test_no_jump_out_of_bare_except_block
(
output
):
output
.
append
(
1
)
try
:
output
.
append
(
3
)
1
/
0
except
:
output
.
append
(
6
)
output
.
append
(
7
)
@jump_test
(
7
,
1
,
[
1
,
3
,
6
],
(
ValueError
,
"out of an 'except'"
))
def
test_no_jump_out_of_qualified_except_block
(
output
):
output
.
append
(
1
)
try
:
output
.
append
(
3
)
1
/
0
except
Exception
:
output
.
append
(
6
)
output
.
append
(
7
)
@jump_test
(
3
,
5
,
[
1
,
2
,
-
2
],
(
ValueError
,
'into'
))
def
test_no_jump_between_with_blocks
(
output
):
...
...
Objects/frameobject.c
Dosyayı görüntüle @
397466df
...
...
@@ -277,8 +277,12 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
int
first_in
=
target_addr
<=
f
->
f_lasti
&&
f
->
f_lasti
<=
addr
;
int
second_in
=
target_addr
<=
new_lasti
&&
new_lasti
<=
addr
;
if
(
first_in
!=
second_in
)
{
PyErr_SetString
(
PyExc_ValueError
,
"can't jump into or out of a 'finally' block"
);
op
=
code
[
target_addr
];
PyErr_Format
(
PyExc_ValueError
,
"can't jump %s %s block"
,
second_in
?
"into"
:
"out of"
,
(
op
==
DUP_TOP
||
op
==
POP_TOP
)
?
"an 'except'"
:
"a 'finally'"
);
return
-
1
;
}
break
;
...
...
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