[packages/python3] Add test patches for sandboxed builds (userns EINVAL, read-only HOME).
arekm
arekm at pld-linux.org
Thu Oct 1 22:08:02 CEST 2026
commit 3903383ffed4e7872dad0d936baea01d11a3d959
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu Oct 1 22:07:02 2026 +0200
Add test patches for sandboxed builds (userns EINVAL, read-only HOME).
python3-test-pyrepl-history.patch | 18 ++++++++++++++++++
python3-test-subprocess-userns.patch | 28 ++++++++++++++++++++++++++++
python3-test-unlink-rofs.patch | 15 +++++++++++++++
python3.spec | 6 ++++++
4 files changed, 67 insertions(+)
---
diff --git a/python3.spec b/python3.spec
index a25beb4..0c8b212 100644
--- a/python3.spec
+++ b/python3.spec
@@ -71,6 +71,9 @@ Patch11: %{name}-installcompile.patch
Patch14: python3-profile-tests.patch
Patch15: python3-tests.patch
+Patch16: python3-test-unlink-rofs.patch
+Patch17: python3-test-subprocess-userns.patch
+Patch18: python3-test-pyrepl-history.patch
URL: https://www.python.org/
BuildRequires: autoconf >= 2.72
BuildRequires: autoconf-archive
@@ -480,6 +483,9 @@ Moduły testowe dla Pythona.
%patch -P 14 -p1
%patch -P 15 -p1
+%patch -P 16 -p1
+%patch -P 17 -p1
+%patch -P 18 -p1
%{__rm} -r Modules/expat
diff --git a/python3-test-pyrepl-history.patch b/python3-test-pyrepl-history.patch
new file mode 100644
index 0000000..ede8993
--- /dev/null
+++ b/python3-test-pyrepl-history.patch
@@ -0,0 +1,18 @@
+Run the pyrepl half of test_no_newline with a temporary PYTHON_HISTORY.
+With env=None run_repl uses -I, which ignores PYTHON_HISTORY, so the REPL
+appends to the real ~/.python_history; with a read-only $HOME the resulting
+warning lands in the checked output.
+
+--- Python-3.14.8/Lib/test/test_pyrepl/test_pyrepl.py
++++ Python-3.14.8/Lib/test/test_pyrepl/test_pyrepl.py
+@@ -1963,7 +1963,9 @@
+ self.assertEqual(basic_exit_code, 0)
+ self.assertIn(expected_output_sequence, basic_output)
+
+- output, exit_code = self.run_repl(commands)
++ env = os.environ.copy()
++ env.pop("PYTHON_BASIC_REPL", None)
++ output, exit_code = self.run_repl(commands, env=env)
+ self.assertEqual(exit_code, 0)
+
+ # Build patterns for escape sequences that don't affect cursor position
diff --git a/python3-test-subprocess-userns.patch b/python3-test-subprocess-userns.patch
new file mode 100644
index 0000000..67079ef
--- /dev/null
+++ b/python3-test-subprocess-userns.patch
@@ -0,0 +1,28 @@
+Make test_subprocess.test_user / test_group tolerate user namespace
+builder sandboxes where setregid / setreuid return EINVAL for unmapped
+uid/gid values instead of EPERM/EACCES.
+
+--- Python-3.13.13/Lib/test/test_subprocess.py.orig 2025-11-10 00:00:00.000000000 +0100
++++ Python-3.13.13/Lib/test/test_subprocess.py 2025-11-10 00:00:00.000000000 +0100
+@@ -2202,6 +2202,10 @@ class POSIXProcessTestCase(BaseTestCase,
+ self.assertEqual(e.filename, sys.executable)
+ else:
+ self.assertIsNone(e.filename)
++ except OSError as e:
++ if e.errno != errno.EINVAL:
++ raise
++ self.skipTest("setreuid() EINVAL; unmapped uid in user namespace")
+ else:
+ if isinstance(user, str):
+ user_uid = pwd.getpwnam(user).pw_uid
+@@ -2248,6 +2252,10 @@ class POSIXProcessTestCase(BaseTestCase,
+ close_fds=close_fds)
+ except PermissionError as e: # (EACCES, EPERM)
+ self.assertIsNone(e.filename)
++ except OSError as e:
++ if e.errno != errno.EINVAL:
++ raise
++ self.skipTest("setregid() EINVAL; unmapped gid in user namespace")
+ else:
+ if isinstance(group, str):
+ group_gid = grp.getgrnam(group).gr_gid
diff --git a/python3-test-unlink-rofs.patch b/python3-test-unlink-rofs.patch
new file mode 100644
index 0000000..e056d1a
--- /dev/null
+++ b/python3-test-unlink-rofs.patch
@@ -0,0 +1,15 @@
+--- Python-3.13.13/Lib/test/support/os_helper.py.orig 2025-11-10 00:00:00.000000000 +0100
++++ Python-3.13.13/Lib/test/support/os_helper.py 2025-11-10 00:00:00.000000000 +0100
+@@ -345,6 +345,12 @@ def unlink(filename):
+ _unlink(filename)
+ except (FileNotFoundError, NotADirectoryError):
+ pass
++ except OSError as e:
++ # On a read-only filesystem, unlink of a non-existent file may
++ # raise EROFS instead of ENOENT. Treat it like a missing file.
++ if e.errno == errno.EROFS and not os.path.lexists(filename):
++ return
++ raise
+
+
+ if sys.platform.startswith("win"):
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/python3.git/commitdiff/3903383ffed4e7872dad0d936baea01d11a3d959
More information about the pld-cvs-commit
mailing list