From c1cf337a827e3d84fa90d5c3928d7da4cd4b7fc96db33a01647ac739c2149b0a Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Fri, 6 Jan 2023 20:58:59 +0000 Subject: [PATCH] - add 684.patch, 715.patch: Python 3.11 support OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pexpect?expand=0&rev=58 --- 684.patch | 23 +++++++++++++++ 715.patch | 67 ++++++++++++++++++++++++++++++++++++++++++ python-pexpect.changes | 5 ++++ python-pexpect.spec | 8 +++-- 4 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 684.patch create mode 100644 715.patch diff --git a/684.patch b/684.patch new file mode 100644 index 0000000..2fad65e --- /dev/null +++ b/684.patch @@ -0,0 +1,23 @@ +From 0bc643ea88748e08a095e3f1a43480c9113d45b8 Mon Sep 17 00:00:00 2001 +From: Karthikeyan Singaravelan +Date: Sat, 17 Apr 2021 08:10:37 +0000 +Subject: [PATCH] Set daemon attribute instead of using setDaemon method that + was deprecated in Python 3.10 + +--- + pexpect/popen_spawn.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/pexpect/popen_spawn.py b/pexpect/popen_spawn.py +index 4bb58cfe..e6bdf07d 100644 +--- a/pexpect/popen_spawn.py ++++ b/pexpect/popen_spawn.py +@@ -57,7 +57,7 @@ def __init__(self, cmd, timeout=30, maxread=2000, searchwindowsize=None, + + self._read_queue = Queue() + self._read_thread = threading.Thread(target=self._read_incoming) +- self._read_thread.setDaemon(True) ++ self._read_thread.daemon = True + self._read_thread.start() + + _read_reached_eof = False diff --git a/715.patch b/715.patch new file mode 100644 index 0000000..93b5e01 --- /dev/null +++ b/715.patch @@ -0,0 +1,67 @@ +From 52af5b0ae0627139524448a3f2e83d9f40802bc2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Thu, 24 Mar 2022 15:15:33 +0100 +Subject: [PATCH] Convert @asyncio.coroutine to async def + +This is required for Python 3.11+ support. + +Fixes https://github.com/pexpect/pexpect/issues/677 +--- + pexpect/_async.py | 16 +++++++--------- + 1 file changed, 7 insertions(+), 9 deletions(-) + +diff --git a/pexpect/_async.py b/pexpect/_async.py +index dfbfeef5..bc83261d 100644 +--- a/pexpect/_async.py ++++ b/pexpect/_async.py +@@ -4,8 +4,7 @@ + + from pexpect import EOF + +-@asyncio.coroutine +-def expect_async(expecter, timeout=None): ++async def expect_async(expecter, timeout=None): + # First process data that was previously read - if it maches, we don't need + # async stuff. + idx = expecter.existing_data() +@@ -14,7 +13,7 @@ def expect_async(expecter, timeout=None): + if not expecter.spawn.async_pw_transport: + pw = PatternWaiter() + pw.set_expecter(expecter) +- transport, pw = yield from asyncio.get_event_loop()\ ++ transport, pw = await asyncio.get_event_loop()\ + .connect_read_pipe(lambda: pw, expecter.spawn) + expecter.spawn.async_pw_transport = pw, transport + else: +@@ -22,26 +21,25 @@ def expect_async(expecter, timeout=None): + pw.set_expecter(expecter) + transport.resume_reading() + try: +- return (yield from asyncio.wait_for(pw.fut, timeout)) ++ return (await asyncio.wait_for(pw.fut, timeout)) + except asyncio.TimeoutError as e: + transport.pause_reading() + return expecter.timeout(e) + +-@asyncio.coroutine +-def repl_run_command_async(repl, cmdlines, timeout=-1): ++async def repl_run_command_async(repl, cmdlines, timeout=-1): + res = [] + repl.child.sendline(cmdlines[0]) + for line in cmdlines[1:]: +- yield from repl._expect_prompt(timeout=timeout, async_=True) ++ await repl._expect_prompt(timeout=timeout, async_=True) + res.append(repl.child.before) + repl.child.sendline(line) + + # Command was fully submitted, now wait for the next prompt +- prompt_idx = yield from repl._expect_prompt(timeout=timeout, async_=True) ++ prompt_idx = await repl._expect_prompt(timeout=timeout, async_=True) + if prompt_idx == 1: + # We got the continuation prompt - command was incomplete + repl.child.kill(signal.SIGINT) +- yield from repl._expect_prompt(timeout=1, async_=True) ++ await repl._expect_prompt(timeout=1, async_=True) + raise ValueError("Continuation prompt found - input was incomplete:") + return u''.join(res + [repl.child.before]) + diff --git a/python-pexpect.changes b/python-pexpect.changes index aae47ad..15fc8fe 100644 --- a/python-pexpect.changes +++ b/python-pexpect.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Jan 6 20:51:12 UTC 2023 - Dirk Müller + +- add 684.patch, 715.patch: Python 3.11 support + ------------------------------------------------------------------- Wed Nov 9 10:07:50 UTC 2022 - Dirk Müller diff --git a/python-pexpect.spec b/python-pexpect.spec index fef23bd..9c17386 100644 --- a/python-pexpect.spec +++ b/python-pexpect.spec @@ -1,7 +1,7 @@ # # spec file for package python-pexpect # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -25,6 +25,9 @@ License: ISC URL: https://pexpect.readthedocs.org/en/latest/ Source: https://files.pythonhosted.org/packages/source/p/pexpect/pexpect-%{version}.tar.gz Patch0: no-python-binary.patch +# Newer asyncio / python 3.11 support +Patch1: https://github.com/pexpect/pexpect/pull/715.patch +Patch2: https://github.com/pexpect/pexpect/pull/684.patch BuildRequires: %{python_module ptyprocess} BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools} @@ -45,8 +48,7 @@ Pexpect is a pure Python module for spawning child applications; controlling them; and responding to expected patterns in their output. %prep -%setup -q -n pexpect-%{version} -%patch0 -p1 +%autosetup -p1 -n pexpect-%{version} # Fix wrong-script-interpreter find examples -type f -name "*.py" -exec sed -i "s|#!%{_bindir}/env python||" {} \;