From 854383ee34ec6934f44346ac5b2661819549ac87 Mon Sep 17 00:00:00 2001 From: yihong0618 Date: Tue, 19 Aug 2025 16:21:50 +0800 Subject: [PATCH 1/2] fix: urllib2 with proxy tests maybe fail on macOS Signed-off-by: yihong0618 --- Lib/test/test_urllib2_localnet.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py index 9186436183aae1..7190b0e5ef2fd6 100644 --- a/Lib/test/test_urllib2_localnet.py +++ b/Lib/test/test_urllib2_localnet.py @@ -351,6 +351,12 @@ def create_fake_proxy_handler(*args, **kwargs): self.server.start() self.server.ready.wait() proxy_url = "http://127.0.0.1:%d" % self.server.port + + # Set http_proxy environment variable to override system proxy settings + # This ensures the proxy is used even on macOS where localhost is + # typically in the proxy bypass list + os.environ['http_proxy'] = proxy_url + handler = urllib.request.ProxyHandler({"http" : proxy_url}) self.proxy_digest_handler = urllib.request.ProxyDigestAuthHandler() self.opener = urllib.request.build_opener( From 651625057da6f6e9270645f502d2774c7ae084be Mon Sep 17 00:00:00 2001 From: yihong0618 Date: Tue, 19 Aug 2025 16:29:27 +0800 Subject: [PATCH 2/2] fix: lint Signed-off-by: yihong0618 --- Lib/test/test_urllib2_localnet.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py index 7190b0e5ef2fd6..a4230554974e39 100644 --- a/Lib/test/test_urllib2_localnet.py +++ b/Lib/test/test_urllib2_localnet.py @@ -351,12 +351,12 @@ def create_fake_proxy_handler(*args, **kwargs): self.server.start() self.server.ready.wait() proxy_url = "http://127.0.0.1:%d" % self.server.port - + # Set http_proxy environment variable to override system proxy settings - # This ensures the proxy is used even on macOS where localhost is + # This ensures the proxy is used even on macOS where localhost is # typically in the proxy bypass list os.environ['http_proxy'] = proxy_url - + handler = urllib.request.ProxyHandler({"http" : proxy_url}) self.proxy_digest_handler = urllib.request.ProxyDigestAuthHandler() self.opener = urllib.request.build_opener(