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
26c9f565
Unverified
Kaydet (Commit)
26c9f565
authored
Mar 11, 2018
tarafından
Serhiy Storchaka
Kaydeden (comit)
GitHub
Mar 11, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-33026: Fix jumping out of "with" block by setting f_lineno. (#6026)
üst
51302a5f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
9 deletions
+44
-9
test_sys_settrace.py
Lib/test/test_sys_settrace.py
+28
-0
2018-03-08-09-48-38.bpo-33026.QZA3Ba.rst
...ore and Builtins/2018-03-08-09-48-38.bpo-33026.QZA3Ba.rst
+1
-0
frameobject.c
Objects/frameobject.c
+15
-9
No files found.
Lib/test/test_sys_settrace.py
Dosyayı görüntüle @
26c9f565
...
@@ -827,6 +827,34 @@ class JumpTestCase(unittest.TestCase):
...
@@ -827,6 +827,34 @@ class JumpTestCase(unittest.TestCase):
with
tracecontext
(
output
,
4
):
with
tracecontext
(
output
,
4
):
output
.
append
(
5
)
output
.
append
(
5
)
@jump_test
(
4
,
5
,
[
1
,
3
,
5
,
6
])
def
test_jump_out_of_with_block_within_for_block
(
output
):
output
.
append
(
1
)
for
i
in
[
1
]:
with
tracecontext
(
output
,
3
):
output
.
append
(
4
)
output
.
append
(
5
)
output
.
append
(
6
)
@jump_test
(
4
,
5
,
[
1
,
2
,
3
,
5
,
-
2
,
6
])
def
test_jump_out_of_with_block_within_with_block
(
output
):
output
.
append
(
1
)
with
tracecontext
(
output
,
2
):
with
tracecontext
(
output
,
3
):
output
.
append
(
4
)
output
.
append
(
5
)
output
.
append
(
6
)
@jump_test
(
5
,
6
,
[
2
,
4
,
6
,
7
])
def
test_jump_out_of_with_block_within_finally_block
(
output
):
try
:
output
.
append
(
2
)
finally
:
with
tracecontext
(
output
,
4
):
output
.
append
(
5
)
output
.
append
(
6
)
output
.
append
(
7
)
@jump_test
(
8
,
11
,
[
1
,
3
,
5
,
11
,
12
])
@jump_test
(
8
,
11
,
[
1
,
3
,
5
,
11
,
12
])
def
test_jump_out_of_complex_nested_blocks
(
output
):
def
test_jump_out_of_complex_nested_blocks
(
output
):
output
.
append
(
1
)
output
.
append
(
1
)
...
...
Misc/NEWS.d/next/Core and Builtins/2018-03-08-09-48-38.bpo-33026.QZA3Ba.rst
0 → 100644
Dosyayı görüntüle @
26c9f565
Fixed jumping out of "with" block by setting f_lineno.
Objects/frameobject.c
Dosyayı görüntüle @
26c9f565
...
@@ -89,7 +89,6 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
...
@@ -89,7 +89,6 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
long
l_new_lineno
;
long
l_new_lineno
;
int
overflow
;
int
overflow
;
int
new_lasti
=
0
;
/* The new value of f_lasti */
int
new_lasti
=
0
;
/* The new value of f_lasti */
int
new_iblock
=
0
;
/* The new value of f_iblock */
unsigned
char
*
code
=
NULL
;
/* The bytecode for the frame... */
unsigned
char
*
code
=
NULL
;
/* The bytecode for the frame... */
Py_ssize_t
code_len
=
0
;
/* ...and its length */
Py_ssize_t
code_len
=
0
;
/* ...and its length */
unsigned
char
*
lnotab
=
NULL
;
/* Iterating over co_lnotab */
unsigned
char
*
lnotab
=
NULL
;
/* Iterating over co_lnotab */
...
@@ -99,6 +98,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
...
@@ -99,6 +98,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
int
addr
=
0
;
/* (ditto) */
int
addr
=
0
;
/* (ditto) */
int
delta_iblock
=
0
;
/* Scanning the SETUPs and POPs */
int
delta_iblock
=
0
;
/* Scanning the SETUPs and POPs */
int
for_loop_delta
=
0
;
/* (ditto) */
int
for_loop_delta
=
0
;
/* (ditto) */
int
delta
;
int
blockstack
[
CO_MAXBLOCKS
];
/* Walking the 'finally' blocks */
int
blockstack
[
CO_MAXBLOCKS
];
/* Walking the 'finally' blocks */
int
blockstack_top
=
0
;
/* (ditto) */
int
blockstack_top
=
0
;
/* (ditto) */
...
@@ -258,19 +258,25 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
...
@@ -258,19 +258,25 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
assert
(
blockstack_top
==
0
);
assert
(
blockstack_top
==
0
);
/* Pop any blocks that we're jumping out of. */
/* Pop any blocks that we're jumping out of. */
new_iblock
=
f
->
f_iblock
-
delta_iblock
;
delta
=
0
;
while
(
f
->
f_iblock
>
new_iblock
)
{
if
(
delta_iblock
>
0
)
{
PyTryBlock
*
b
=
&
f
->
f_blockstack
[
--
f
->
f_iblock
];
f
->
f_iblock
-=
delta_iblock
;
while
((
f
->
f_stacktop
-
f
->
f_valuestack
)
>
b
->
b_level
)
{
PyTryBlock
*
b
=
&
f
->
f_blockstack
[
f
->
f_iblock
];
PyObject
*
v
=
(
*--
f
->
f_stacktop
);
delta
=
(
f
->
f_stacktop
-
f
->
f_valuestack
)
-
b
->
b_level
;
Py_DECREF
(
v
);
if
(
b
->
b_type
==
SETUP_FINALLY
&&
code
[
b
->
b_handler
]
==
WITH_CLEANUP_START
)
{
/* Pop the exit function. */
delta
++
;
}
}
}
}
/* Pop the iterators of any 'for' loop we're jumping out of. */
/* Pop the iterators of any 'for' loop we're jumping out of. */
while
(
for_loop_delta
>
0
)
{
delta
+=
for_loop_delta
;
while
(
delta
>
0
)
{
PyObject
*
v
=
(
*--
f
->
f_stacktop
);
PyObject
*
v
=
(
*--
f
->
f_stacktop
);
Py_DECREF
(
v
);
Py_DECREF
(
v
);
for_loop_
delta
--
;
delta
--
;
}
}
/* Finally set the new f_lineno and f_lasti and return OK. */
/* Finally set the new f_lineno and f_lasti and return OK. */
...
...
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