Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exposeFunction causes exception #443

Open
aont opened this issue Jun 27, 2023 · 1 comment
Open

exposeFunction causes exception #443

aont opened this issue Jun 27, 2023 · 1 comment

Comments

@aont
Copy link

aont commented Jun 27, 2023

OS: Windows 10 22H2 19045.3086 x64
Python 3.11.4 x64
pyppeteer: 1.0.2

When Page.exposeFunction is called, an exception occurs:

  File "pyppeteer\page.py", line 610, in exposeFunction
    await asyncio.wait([_evaluate(frame, expression) for frame in self.frames])
  File "asyncio\tasks.py", line 415, in wait
    TypeError: Passing coroutines is forbidden, use tasks explicitly.

My suggestion:

# file: page.py exposeFunction()

# before
await asyncio.wait([_evaluate(frame, expression) for frame in self.frames])

# after
loop = asyncio.get_event_loop()
await asyncio.wait([loop.create_task(_evaluate(frame, expression)) for frame in self.frames])
greedystack added a commit to greedystack/pyppeteer that referenced this issue Oct 13, 2023
This leds to `TypeError: Passing coroutines is forbidden, use tasks explicitly.`

See pyppeteer#443
@greedystack
Copy link
Contributor

Same bug. Very clear, that this had to happen - Passing coroutines was deprecated and has been removed in 3.11.
Python 3.11
pyppeteer: 1.0.2
OS: MacOS 14.0

The fix from @aont works. Created a PR: #451

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants