Revert "Make PyProxy of async iterator JavaScript async iterables"

This reverts commit 45104830ea.
This commit is contained in:
Hood Chatham 2023-03-28 16:35:46 -07:00
parent 45104830ea
commit 1e2f75d4e7
2 changed files with 2 additions and 63 deletions

View File

@ -1265,10 +1265,6 @@ export class PyAsyncIterator extends PyProxy {
export interface PyAsyncIterator extends PyAsyncIteratorMethods {}
export class PyAsyncIteratorMethods {
/** @private */
[Symbol.asyncIterator]() {
return this;
}
/**
* This translates to the Python code ``anext(obj)``. Returns the next value
* of the asynchronous iterator. The argument will be sent to the Python

View File

@ -1063,7 +1063,7 @@ def test_pyproxy_this2(selenium):
@run_in_pyodide
async def test_async_iter1(selenium):
async def test_async_iter(selenium):
from pyodide.code import run_js
class Gen:
@ -1089,41 +1089,6 @@ async def test_async_iter1(selenium):
assert (await p).to_py() == [1, 2]
@run_in_pyodide
async def test_async_iter2(selenium):
from pyodide.code import run_js
class Gen:
def __init__(self):
self.i = 0
def __aiter__(self):
return self
async def __anext__(self):
self.i += 1
if self.i > 2:
raise StopAsyncIteration
return self.i
g = Gen()
p = run_js(
"""
async (g) => {
assert(() => g instanceof pyodide.ffi.PyAsyncIterable);
let r = [];
for await (let a of g) {
r.push(a);
}
return r;
}
"""
)(g)
assert (await p).to_py() == [1, 2]
@run_in_pyodide
def test_gen(selenium):
from pyodide.code import run_js
@ -1291,7 +1256,7 @@ def test_gen_throw(selenium):
@run_in_pyodide
async def test_async_gen1(selenium):
async def test_async_gen(selenium):
from pyodide.code import run_js
async def g():
@ -1324,28 +1289,6 @@ async def test_async_gen1(selenium):
]
@run_in_pyodide
async def test_async_gen2(selenium):
from pyodide.code import run_js
async def g():
for n in range(3):
yield n
p = run_js(
"""
async (g) => {
let result = [];
for await (let x of g){
result.push(x);
}
return result;
}
"""
)(g())
assert (await p).to_py() == [0, 1, 2]
@run_in_pyodide
async def test_async_gen_return(selenium):
from pyodide.code import run_js