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
91427733
Kaydet (Commit)
91427733
authored
Mar 11, 2015
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #23192: Fixed generator lambdas. Patch by Bruno Cauet.
üst
354ecf1e
c775ad61
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
2 deletions
+24
-2
test_generators.py
Lib/test/test_generators.py
+20
-0
NEWS
Misc/NEWS
+2
-0
compile.c
Python/compile.c
+2
-2
No files found.
Lib/test/test_generators.py
Dosyayı görüntüle @
91427733
...
...
@@ -49,6 +49,26 @@ class FinalizationTest(unittest.TestCase):
self
.
assertTrue
(
finalized
)
self
.
assertEqual
(
gc
.
garbage
,
old_garbage
)
def
test_lambda_generator
(
self
):
# Issue #23192: Test that a lambda returning a generator behaves
# like the equivalent function
f
=
lambda
:
(
yield
1
)
def
g
():
return
(
yield
1
)
# test 'yield from'
f2
=
lambda
:
(
yield
from
g
())
def
g2
():
return
(
yield
from
g
())
f3
=
lambda
:
(
yield
from
f
())
def
g3
():
return
(
yield
from
f
())
for
gen_fun
in
(
f
,
g
,
f2
,
g2
,
f3
,
g3
):
gen
=
gen_fun
()
self
.
assertEqual
(
next
(
gen
),
1
)
with
self
.
assertRaises
(
StopIteration
)
as
cm
:
gen
.
send
(
2
)
self
.
assertEqual
(
cm
.
exception
.
value
,
2
)
class
GeneratorTest
(
unittest
.
TestCase
):
...
...
Misc/NEWS
Dosyayı görüntüle @
91427733
...
...
@@ -10,6 +10,8 @@ Release date: 2015-03-28
Core and Builtins
-----------------
- Issue #23192: Fixed generator lambdas. Patch by Bruno Cauet.
- Issue #23629: Fix the default __sizeof__ implementation for variable-sized
objects.
...
...
Python/compile.c
Dosyayı görüntüle @
91427733
...
...
@@ -1897,12 +1897,12 @@ compiler_lambda(struct compiler *c, expr_ty e)
c
->
u
->
u_kwonlyargcount
=
asdl_seq_LEN
(
args
->
kwonlyargs
);
VISIT_IN_SCOPE
(
c
,
expr
,
e
->
v
.
Lambda
.
body
);
if
(
c
->
u
->
u_ste
->
ste_generator
)
{
ADDOP_IN_SCOPE
(
c
,
POP_TOP
);
co
=
assemble
(
c
,
0
);
}
else
{
ADDOP_IN_SCOPE
(
c
,
RETURN_VALUE
);
co
=
assemble
(
c
,
1
);
}
co
=
assemble
(
c
,
1
);
qualname
=
c
->
u
->
u_qualname
;
Py_INCREF
(
qualname
);
compiler_exit_scope
(
c
);
...
...
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