commit:     70c13d4b58cd883d2a1029d560b642c0416a66aa
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat May 10 19:23:06 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat May 10 19:23:06 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=70c13d4b

dev-python/pexpect: enable py3.14

Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-python/pexpect/files/pexpect-4.9.0-py314.patch | 107 +++++++++++++++++++++
 dev-python/pexpect/pexpect-4.9.0.ebuild            |   4 +-
 2 files changed, 110 insertions(+), 1 deletion(-)

diff --git a/dev-python/pexpect/files/pexpect-4.9.0-py314.patch 
b/dev-python/pexpect/files/pexpect-4.9.0-py314.patch
new file mode 100644
index 000000000000..a7d1f8f83593
--- /dev/null
+++ b/dev-python/pexpect/files/pexpect-4.9.0-py314.patch
@@ -0,0 +1,107 @@
+https://github.com/pexpect/pexpect/commit/456bc10d94b57e254568e7ea9a8b3cffb856ebff
+
+From 456bc10d94b57e254568e7ea9a8b3cffb856ebff Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <[email protected]>
+Date: Fri, 22 Nov 2024 16:41:55 +0100
+Subject: [PATCH] Tests: Avoid the multiprocessing forkserver method
+
+Fixes https://github.com/pexpect/pexpect/issues/807
+---
+ tests/test_expect.py | 12 ++++++++++--
+ tests/test_socket.py | 24 ++++++++++++++++--------
+ 2 files changed, 26 insertions(+), 10 deletions(-)
+
+diff --git a/tests/test_expect.py b/tests/test_expect.py
+index c16e0551..fb1e30e2 100755
+--- a/tests/test_expect.py
++++ b/tests/test_expect.py
+@@ -33,6 +33,14 @@
+ 
+ PY3 = bool(sys.version_info.major >= 3)
+ 
++# Python 3.14 changed the non-macOS POSIX default to forkserver
++# but the code in this module does not work with it
++# See https://github.com/python/cpython/issues/125714
++if multiprocessing.get_start_method() == 'forkserver':
++    mp_context = multiprocessing.get_context(method='fork')
++else:
++    mp_context = multiprocessing.get_context()
++
+ # Many of these test cases blindly assume that sequential directory
+ # listings of the /bin directory will yield the same results.
+ # This may not be true, but seems adequate for testing now.
+@@ -682,7 +690,7 @@ def test_stdin_closed(self):
+         '''
+         Ensure pexpect continues to operate even when stdin is closed
+         '''
+-        class Closed_stdin_proc(multiprocessing.Process):
++        class Closed_stdin_proc(mp_context.Process):
+             def run(self):
+                 sys.__stdin__.close()
+                 cat = pexpect.spawn('cat')
+@@ -698,7 +706,7 @@ def test_stdin_stdout_closed(self):
+         '''
+         Ensure pexpect continues to operate even when stdin and stdout is 
closed
+         '''
+-        class Closed_stdin_stdout_proc(multiprocessing.Process):
++        class Closed_stdin_stdout_proc(mp_context.Process):
+             def run(self):
+                 sys.__stdin__.close()
+                 sys.__stdout__.close()
+diff --git a/tests/test_socket.py b/tests/test_socket.py
+index b801b00a..6521d368 100644
+--- a/tests/test_socket.py
++++ b/tests/test_socket.py
+@@ -29,6 +29,14 @@
+ import time
+ import errno
+ 
++# Python 3.14 changed the non-macOS POSIX default to forkserver
++# but the code in this module does not work with it
++# See https://github.com/python/cpython/issues/125714
++if multiprocessing.get_start_method() == 'forkserver':
++    mp_context = multiprocessing.get_context(method='fork')
++else:
++    mp_context = multiprocessing.get_context()
++
+ 
+ class SocketServerError(Exception):
+     pass
+@@ -83,8 +91,8 @@ def setUp(self):
+         self.prompt3 = b'Press X to exit:'
+         self.enter = b'\r\n'
+         self.exit = b'X\r\n'
+-        self.server_up = multiprocessing.Event()
+-        self.server_process = 
multiprocessing.Process(target=self.socket_server, args=(self.server_up,))
++        self.server_up = mp_context.Event()
++        self.server_process = mp_context.Process(target=self.socket_server, 
args=(self.server_up,))
+         self.server_process.daemon = True
+         self.server_process.start()
+         counter = 0
+@@ -189,9 +197,9 @@ def test_timeout(self):
+             session.expect(b'Bogus response')
+ 
+     def test_interrupt(self):
+-        timed_out = multiprocessing.Event()
+-        all_read = multiprocessing.Event()
+-        test_proc = multiprocessing.Process(target=self.socket_fn, 
args=(timed_out, all_read))
++        timed_out = mp_context.Event()
++        all_read = mp_context.Event()
++        test_proc = mp_context.Process(target=self.socket_fn, 
args=(timed_out, all_read))
+         test_proc.daemon = True
+         test_proc.start()
+         while not all_read.is_set():
+@@ -203,9 +211,9 @@ def test_interrupt(self):
+         self.assertEqual(test_proc.exitcode, errno.ETIMEDOUT)
+ 
+     def test_multiple_interrupts(self):
+-        timed_out = multiprocessing.Event()
+-        all_read = multiprocessing.Event()
+-        test_proc = multiprocessing.Process(target=self.socket_fn, 
args=(timed_out, all_read))
++        timed_out = mp_context.Event()
++        all_read = mp_context.Event()
++        test_proc = mp_context.Process(target=self.socket_fn, 
args=(timed_out, all_read))
+         test_proc.daemon = True
+         test_proc.start()
+         while not all_read.is_set():
+

diff --git a/dev-python/pexpect/pexpect-4.9.0.ebuild 
b/dev-python/pexpect/pexpect-4.9.0.ebuild
index 325f441e2429..fe72a02d12cd 100644
--- a/dev-python/pexpect/pexpect-4.9.0.ebuild
+++ b/dev-python/pexpect/pexpect-4.9.0.ebuild
@@ -4,7 +4,7 @@
 EAPI=8
 
 DISTUTILS_USE_PEP517=setuptools
-PYTHON_COMPAT=( python3_{10..13} python3_13t pypy3 pypy3_11 )
+PYTHON_COMPAT=( python3_{10..14} python3_13t pypy3 pypy3_11 )
 PYTHON_REQ_USE="threads(+)"
 
 inherit distutils-r1 pypi
@@ -32,6 +32,8 @@ distutils_enable_sphinx doc \
 PATCHES=(
        # https://github.com/pexpect/pexpect/pull/794
        "${FILESDIR}/${P}-py313.patch"
+       # https://github.com/pexpect/pexpect/pull/808
+       "${FILESDIR}/${P}-py314.patch"
 )
 
 src_test() {

Reply via email to