aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2020-05-17 10:55:22 +0200
committerMichał Górny <mgorny@gentoo.org>2020-05-17 11:37:45 +0200
commitc35f39af1ae591c9df50da52e83067428a10f80a (patch)
tree1ec6b2efaf9b5f255ff4ce66538d1cddc6e0314a
parentlocks: translate surrogate from uname (bug 721402) (diff)
downloadportage-c35f39af1ae591c9df50da52e83067428a10f80a.tar.gz
portage-c35f39af1ae591c9df50da52e83067428a10f80a.tar.bz2
portage-c35f39af1ae591c9df50da52e83067428a10f80a.zip
process: Provide libc fallback for sethostname() on PyPy
Reviewed-by: Zac Medico <zmedico@gentoo.org> Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r--lib/portage/process.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/portage/process.py b/lib/portage/process.py
index 79052b608..ceb454030 100644
--- a/lib/portage/process.py
+++ b/lib/portage/process.py
@@ -715,7 +715,14 @@ def _exec(binary, mycommand, opt_name, fd_pipes,
if unshare_net:
# use 'localhost' to avoid hostname resolution problems
try:
- socket.sethostname('localhost')
+ # pypy3 does not implement socket.sethostname()
+ new_hostname = b'localhost'
+ if hasattr(socket, 'sethostname'):
+ socket.sethostname(new_hostname)
+ else:
+ if libc.sethostname(new_hostname, len(new_hostname)) != 0:
+ errno_value = ctypes.get_errno()
+ raise OSError(errno_value, os.strerror(errno_value))
except Exception as e:
writemsg("Unable to set hostname: %s (for FEATURES=\"network-sandbox\")\n" % (
e,),