Skip to content

Commit 32e5ce8

Browse files
authored
chore: nit fixes (microsoft#441)
1 parent 30946ae commit 32e5ce8

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

playwright/_impl/_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def navigation_timeout(self) -> float:
150150

151151

152152
def serialize_error(ex: Exception, tb: Optional[TracebackType]) -> ErrorPayload:
153-
return dict(message=str(ex), stack="".join(traceback.format_tb(tb)))
153+
return dict(message=str(ex), name="Error", stack="".join(traceback.format_tb(tb)))
154154

155155

156156
def parse_error(error: ErrorPayload) -> Error:

playwright/_impl/_page.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -949,11 +949,13 @@ async def call(self, func: Callable) -> None:
949949
else:
950950
func_args = list(map(parse_result, self._initializer["args"]))
951951
result = func(source, *func_args)
952-
if asyncio.isfuture(result):
952+
if inspect.iscoroutine(result):
953953
result = await result
954954
await self._channel.send("resolve", dict(result=serialize_argument(result)))
955955
except Exception as e:
956956
tb = sys.exc_info()[2]
957957
asyncio.create_task(
958-
self._channel.send("reject", dict(error=serialize_error(e, tb)))
958+
self._channel.send(
959+
"reject", dict(error=dict(error=serialize_error(e, tb)))
960+
)
959961
)

tests/async/test_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ async def test_expose_function_should_await_returned_promise(page):
351351
async def mul(a, b):
352352
return a * b
353353

354-
await page.expose_function("compute", lambda a, b: asyncio.create_task(mul(a, b)))
354+
await page.expose_function("compute", mul)
355355
assert await page.evaluate("compute(3, 5)") == 15
356356

357357

0 commit comments

Comments
 (0)