commit:     d00ecdce359c8bc3d3520aef58d5808c7d15020b
Author:     Pavel Balaev <mail <AT> void <DOT> so>
AuthorDate: Wed Mar 20 14:35:54 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun May 26 23:27:07 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=d00ecdce

process: make has_ipv6 a public function

Signed-off-by: Pavel Balaev <mail <AT> void.so>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/process.py                        | 8 ++++----
 lib/portage/tests/process/test_unshare_net.py | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/portage/process.py b/lib/portage/process.py
index 1bc0c507c2..6e4e0d7162 100644
--- a/lib/portage/process.py
+++ b/lib/portage/process.py
@@ -631,8 +631,8 @@ def spawn(
         fd_pipes[1] = pw
         fd_pipes[2] = pw
 
-    # Cache _has_ipv6() result for use in child processes.
-    _has_ipv6()
+    # Cache has_ipv6() result for use in child processes.
+    has_ipv6()
 
     # This caches the libc library lookup and _unshare_validator results
     # in the current process, so that results are cached for use in
@@ -751,7 +751,7 @@ def spawn(
 __has_ipv6 = None
 
 
-def _has_ipv6():
+def has_ipv6():
     """
     Test that both userland and kernel support IPv6, by attempting
     to create a socket and listen on any unused port of the IPv6
@@ -812,7 +812,7 @@ def _configure_loopback_interface():
             ifindex = rtnl.get_link_ifindex(b"lo")
             rtnl.set_link_up(ifindex)
             rtnl.add_address(ifindex, socket.AF_INET, "10.0.0.1", 8)
-            if _has_ipv6():
+            if has_ipv6():
                 rtnl.add_address(ifindex, socket.AF_INET6, "fd::1", 8)
     except OSError as e:
         writemsg(

diff --git a/lib/portage/tests/process/test_unshare_net.py 
b/lib/portage/tests/process/test_unshare_net.py
index ad3b288ef4..56d96da05f 100644
--- a/lib/portage/tests/process/test_unshare_net.py
+++ b/lib/portage/tests/process/test_unshare_net.py
@@ -42,7 +42,7 @@ class UnshareNetTestCase(TestCase):
                 f"Unable to unshare: 
{errno.errorcode.get(self.ABILITY_TO_UNSHARE, '?')}"
             )
         env = os.environ.copy()
-        env["IPV6"] = "1" if portage.process._has_ipv6() else ""
+        env["IPV6"] = "1" if portage.process.has_ipv6() else ""
         self.assertEqual(
             portage.process.spawn(
                 [BASH_BINARY, "-c", UNSHARE_NET_TEST_SCRIPT], 
unshare_net=True, env=env

Reply via email to