PageRenderTime 52ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/dev-python/pexpect/files/pexpect-4.8.0-py311.patch

https://gitlab.com/redcore/portage
Patch | 67 lines | 59 code | 8 blank | 0 comment | 0 complexity | 39bd92dbc29009b58fbcbe440e77454c MD5 | raw file
  1. From 52af5b0ae0627139524448a3f2e83d9f40802bc2 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
  3. Date: Thu, 24 Mar 2022 15:15:33 +0100
  4. Subject: [PATCH] Convert @asyncio.coroutine to async def
  5. This is required for Python 3.11+ support.
  6. Fixes https://github.com/pexpect/pexpect/issues/677
  7. ---
  8. pexpect/_async.py | 16 +++++++---------
  9. 1 file changed, 7 insertions(+), 9 deletions(-)
  10. diff --git a/pexpect/_async.py b/pexpect/_async.py
  11. index dfbfeef5..bc83261d 100644
  12. --- a/pexpect/_async.py
  13. +++ b/pexpect/_async.py
  14. @@ -4,8 +4,7 @@
  15. from pexpect import EOF
  16. -@asyncio.coroutine
  17. -def expect_async(expecter, timeout=None):
  18. +async def expect_async(expecter, timeout=None):
  19. # First process data that was previously read - if it maches, we don't need
  20. # async stuff.
  21. idx = expecter.existing_data()
  22. @@ -14,7 +13,7 @@ def expect_async(expecter, timeout=None):
  23. if not expecter.spawn.async_pw_transport:
  24. pw = PatternWaiter()
  25. pw.set_expecter(expecter)
  26. - transport, pw = yield from asyncio.get_event_loop()\
  27. + transport, pw = await asyncio.get_event_loop()\
  28. .connect_read_pipe(lambda: pw, expecter.spawn)
  29. expecter.spawn.async_pw_transport = pw, transport
  30. else:
  31. @@ -22,26 +21,25 @@ def expect_async(expecter, timeout=None):
  32. pw.set_expecter(expecter)
  33. transport.resume_reading()
  34. try:
  35. - return (yield from asyncio.wait_for(pw.fut, timeout))
  36. + return (await asyncio.wait_for(pw.fut, timeout))
  37. except asyncio.TimeoutError as e:
  38. transport.pause_reading()
  39. return expecter.timeout(e)
  40. -@asyncio.coroutine
  41. -def repl_run_command_async(repl, cmdlines, timeout=-1):
  42. +async def repl_run_command_async(repl, cmdlines, timeout=-1):
  43. res = []
  44. repl.child.sendline(cmdlines[0])
  45. for line in cmdlines[1:]:
  46. - yield from repl._expect_prompt(timeout=timeout, async_=True)
  47. + await repl._expect_prompt(timeout=timeout, async_=True)
  48. res.append(repl.child.before)
  49. repl.child.sendline(line)
  50. # Command was fully submitted, now wait for the next prompt
  51. - prompt_idx = yield from repl._expect_prompt(timeout=timeout, async_=True)
  52. + prompt_idx = await repl._expect_prompt(timeout=timeout, async_=True)
  53. if prompt_idx == 1:
  54. # We got the continuation prompt - command was incomplete
  55. repl.child.kill(signal.SIGINT)
  56. - yield from repl._expect_prompt(timeout=1, async_=True)
  57. + await repl._expect_prompt(timeout=1, async_=True)
  58. raise ValueError("Continuation prompt found - input was incomplete:")
  59. return u''.join(res + [repl.child.before])