From 821a509064e008f17b5b654ccaba051a2eee4479 Mon Sep 17 00:00:00 2001 From: Skye Date: Mon, 9 Feb 2026 10:11:21 +0900 Subject: [PATCH] work around GraalPy's broken `inet_pton` on Java backend --- copyparty/util.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/copyparty/util.py b/copyparty/util.py index 78d403f2..d680b5af 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -270,6 +270,20 @@ try: socket.inet_pton(socket.AF_INET6, "::1") HAVE_IPV6 = True + + if GRAAL: + try: + # --python.PosixModuleBackend=java throws OSError: illegal IP address + socket.inet_pton(socket.AF_INET, "127.0.0.1") + except: + _inet_pton = socket.inet_pton + + def inet_pton(fam, ip): + if fam == socket.AF_INET: + return socket.inet_aton(ip) + return _inet_pton(fam, ip) + + socket.inet_pton = inet_pton except: def inet_pton(fam, ip):