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
94c22630
Kaydet (Commit)
94c22630
authored
Haz 04, 2015
tarafından
Yury Selivanov
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 24374: Plug refleak in set_coroutine_wrapper
üst
53f95024
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
33 deletions
+21
-33
test_coroutines.py
Lib/test/test_coroutines.py
+2
-2
ceval.c
Python/ceval.c
+19
-31
No files found.
Lib/test/test_coroutines.py
Dosyayı görüntüle @
94c22630
...
@@ -1006,10 +1006,10 @@ class SysSetCoroWrapperTest(unittest.TestCase):
...
@@ -1006,10 +1006,10 @@ class SysSetCoroWrapperTest(unittest.TestCase):
sys
.
set_coroutine_wrapper
(
wrapper
)
sys
.
set_coroutine_wrapper
(
wrapper
)
try
:
try
:
with
self
.
assertRaisesRegex
(
with
s
ilence_coro_gc
(),
s
elf
.
assertRaisesRegex
(
RuntimeError
,
RuntimeError
,
"coroutine wrapper.*
\
.wrapper at 0x.*attempted to "
"coroutine wrapper.*
\
.wrapper at 0x.*attempted to "
"recursively wrap
<coroutine.*
\
.wrap
"
):
"recursively wrap
.* wrap .*
"
):
foo
()
foo
()
finally
:
finally
:
...
...
Python/ceval.c
Dosyayı görüntüle @
94c22630
...
@@ -146,8 +146,6 @@ static void format_exc_unbound(PyCodeObject *co, int oparg);
...
@@ -146,8 +146,6 @@ static void format_exc_unbound(PyCodeObject *co, int oparg);
static
PyObject
*
unicode_concatenate
(
PyObject
*
,
PyObject
*
,
static
PyObject
*
unicode_concatenate
(
PyObject
*
,
PyObject
*
,
PyFrameObject
*
,
unsigned
char
*
);
PyFrameObject
*
,
unsigned
char
*
);
static
PyObject
*
special_lookup
(
PyObject
*
,
_Py_Identifier
*
);
static
PyObject
*
special_lookup
(
PyObject
*
,
_Py_Identifier
*
);
static
PyObject
*
apply_coroutine_wrapper
(
PyObject
*
);
#define NAME_ERROR_MSG \
#define NAME_ERROR_MSG \
"name '%.200s' is not defined"
"name '%.200s' is not defined"
...
@@ -3923,6 +3921,18 @@ _PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals,
...
@@ -3923,6 +3921,18 @@ _PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals,
if
(
co
->
co_flags
&
CO_GENERATOR
)
{
if
(
co
->
co_flags
&
CO_GENERATOR
)
{
PyObject
*
gen
;
PyObject
*
gen
;
PyObject
*
coro_wrapper
=
tstate
->
coroutine_wrapper
;
int
is_coro
=
co
->
co_flags
&
(
CO_COROUTINE
|
CO_ITERABLE_COROUTINE
);
if
(
is_coro
&&
tstate
->
in_coroutine_wrapper
)
{
assert
(
coro_wrapper
!=
NULL
);
PyErr_Format
(
PyExc_RuntimeError
,
"coroutine wrapper %.200R attempted "
"to recursively wrap %.200R"
,
coro_wrapper
,
co
);
goto
fail
;
}
/* Don't need to keep the reference to f_back, it will be set
/* Don't need to keep the reference to f_back, it will be set
* when the generator is resumed. */
* when the generator is resumed. */
...
@@ -3936,8 +3946,13 @@ _PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals,
...
@@ -3936,8 +3946,13 @@ _PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals,
if
(
gen
==
NULL
)
if
(
gen
==
NULL
)
return
NULL
;
return
NULL
;
if
(
co
->
co_flags
&
(
CO_COROUTINE
|
CO_ITERABLE_COROUTINE
))
if
(
is_coro
&&
coro_wrapper
!=
NULL
)
{
return
apply_coroutine_wrapper
(
gen
);
PyObject
*
wrapped
;
tstate
->
in_coroutine_wrapper
=
1
;
wrapped
=
PyObject_CallFunction
(
coro_wrapper
,
"N"
,
gen
);
tstate
->
in_coroutine_wrapper
=
0
;
return
wrapped
;
}
return
gen
;
return
gen
;
}
}
...
@@ -5232,33 +5247,6 @@ unicode_concatenate(PyObject *v, PyObject *w,
...
@@ -5232,33 +5247,6 @@ unicode_concatenate(PyObject *v, PyObject *w,
return
res
;
return
res
;
}
}
static
PyObject
*
apply_coroutine_wrapper
(
PyObject
*
gen
)
{
PyObject
*
wrapped
;
PyThreadState
*
tstate
=
PyThreadState_GET
();
PyObject
*
wrapper
=
tstate
->
coroutine_wrapper
;
if
(
tstate
->
in_coroutine_wrapper
)
{
assert
(
wrapper
!=
NULL
);
PyErr_Format
(
PyExc_RuntimeError
,
"coroutine wrapper %.200R attempted "
"to recursively wrap %.200R"
,
wrapper
,
gen
);
return
NULL
;
}
if
(
wrapper
==
NULL
)
{
return
gen
;
}
tstate
->
in_coroutine_wrapper
=
1
;
wrapped
=
PyObject_CallFunction
(
wrapper
,
"N"
,
gen
);
tstate
->
in_coroutine_wrapper
=
0
;
return
wrapped
;
}
#ifdef DYNAMIC_EXECUTION_PROFILE
#ifdef DYNAMIC_EXECUTION_PROFILE
static
PyObject
*
static
PyObject
*
...
...
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