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
398ff91a
Kaydet (Commit)
398ff91a
authored
Mar 03, 2017
tarafından
Yury Selivanov
Kaydeden (comit)
GitHub
Mar 03, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-28893: Set __cause__ for errors in async iteration protocol (#407)
üst
8d26aa93
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
3 deletions
+44
-3
test_coroutines.py
Lib/test/test_coroutines.py
+38
-0
NEWS
Misc/NEWS
+3
-0
ceval.c
Python/ceval.c
+3
-3
No files found.
Lib/test/test_coroutines.py
Dosyayı görüntüle @
398ff91a
...
...
@@ -1680,6 +1680,44 @@ class CoroutineTest(unittest.TestCase):
warnings
.
simplefilter
(
"error"
)
run_async
(
foo
())
def
test_for_11
(
self
):
class
F
:
def
__aiter__
(
self
):
return
self
def
__anext__
(
self
):
return
self
def
__await__
(
self
):
1
/
0
async
def
main
():
async
for
_
in
F
():
pass
with
self
.
assertRaisesRegex
(
TypeError
,
'an invalid object from __anext__'
)
as
c
:
main
()
.
send
(
None
)
err
=
c
.
exception
self
.
assertIsInstance
(
err
.
__cause__
,
ZeroDivisionError
)
def
test_for_12
(
self
):
class
F
:
def
__aiter__
(
self
):
return
self
def
__await__
(
self
):
1
/
0
async
def
main
():
async
for
_
in
F
():
pass
with
self
.
assertRaisesRegex
(
TypeError
,
'an invalid object from __aiter__'
)
as
c
:
main
()
.
send
(
None
)
err
=
c
.
exception
self
.
assertIsInstance
(
err
.
__cause__
,
ZeroDivisionError
)
def
test_for_tuple
(
self
):
class
Done
(
Exception
):
pass
...
...
Misc/NEWS
Dosyayı görüntüle @
398ff91a
...
...
@@ -10,6 +10,9 @@ What's New in Python 3.7.0 alpha 1?
Core and Builtins
-----------------
- bpo-28893: Set correct __cause__ for errors about invalid awaitables
returned from __aiter__ and __anext__.
- bpo-29683: Fixes to memory allocation in _PyCode_SetExtra. Patch by
Brian Coleman.
...
...
Python/ceval.c
Dosyayı görüntüle @
398ff91a
...
...
@@ -1855,13 +1855,13 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
awaitable
=
_PyCoro_GetAwaitableIter
(
iter
);
if
(
awaitable
==
NULL
)
{
SET_TOP
(
NULL
);
PyErr_Format
(
_PyErr_FormatFromCause
(
PyExc_TypeError
,
"'async for' received an invalid object "
"from __aiter__: %.100s"
,
Py_TYPE
(
iter
)
->
tp_name
);
SET_TOP
(
NULL
);
Py_DECREF
(
iter
);
goto
error
;
}
else
{
...
...
@@ -1920,7 +1920,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
awaitable
=
_PyCoro_GetAwaitableIter
(
next_iter
);
if
(
awaitable
==
NULL
)
{
PyErr_Format
(
_PyErr_FormatFromCause
(
PyExc_TypeError
,
"'async for' received an invalid object "
"from __anext__: %.100s"
,
...
...
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