File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -543,8 +543,6 @@ async def consume():
543543 self .loop .run_until_complete (consume ())
544544 self .assertEqual (results , [1 , 2 ])
545545
546- # TODO: RUSTPYTHON, NameError: name 'aiter' is not defined
547- @unittest .expectedFailure
548546 def test_aiter_idempotent (self ):
549547 async def gen ():
550548 yield 1
@@ -766,8 +764,6 @@ def run_test(test):
766764 run_test (test5 )
767765 run_test (test6 )
768766
769- # TODO: RUSTPYTHON, NameError: name 'aiter' is not defined
770- @unittest .expectedFailure
771767 def test_aiter_bad_args (self ):
772768 async def gen ():
773769 yield 1
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ mod builtins {
1212 use crate :: compile;
1313 use crate :: {
1414 builtins:: {
15+ asyncgenerator:: PyAsyncGen ,
1516 enumerate:: PyReverseSequenceIterator ,
1617 function:: { PyCellRef , PyFunctionRef } ,
1718 int:: PyIntRef ,
@@ -426,6 +427,15 @@ mod builtins {
426427 }
427428 }
428429
430+ #[ pyfunction]
431+ fn aiter ( iter_target : PyObjectRef , vm : & VirtualMachine ) -> PyResult {
432+ if iter_target. payload_is :: < PyAsyncGen > ( ) {
433+ vm. call_special_method ( iter_target, "__aiter__" , ( ) )
434+ } else {
435+ Err ( vm. new_type_error ( "wrong argument type" . to_owned ( ) ) )
436+ }
437+ }
438+
429439 #[ pyfunction]
430440 fn len ( obj : PyObjectRef , vm : & VirtualMachine ) -> PyResult < usize > {
431441 obj. length ( vm)
You can’t perform that action at this time.
0 commit comments