From b56dba57f5a706a2cf260b129a2fcc52f7805562 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 19 Oct 2026 12:34:31 -0700 Subject: [PATCH] gh-159739: Propagate macOS proxy conversion errors Propagate Python exceptions from Core Foundation string conversion instead of returning a result with an exception set. Backport to 3.15 and 3.14. --- .../next/macOS/2026-10-19-19-33-35.gh-issue-159739.aaf575.rst | 1 + Modules/_scproxy.c | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/macOS/2026-10-19-19-33-35.gh-issue-159739.aaf575.rst diff --git a/Misc/NEWS.d/next/macOS/2026-10-19-19-33-35.gh-issue-159739.aaf575.rst b/Misc/NEWS.d/next/macOS/2026-10-19-19-33-35.gh-issue-159739.aaf575.rst new file mode 100644 index 00000000000000..0e29daaa307e22 --- /dev/null +++ b/Misc/NEWS.d/next/macOS/2026-10-19-19-33-35.gh-issue-159739.aaf575.rst @@ -0,0 +1 @@ +Propagate errors that occur while converting macOS system proxy settings. diff --git a/Modules/_scproxy.c b/Modules/_scproxy.c index e9170f2ce1ae87..94163197a3a2e3 100644 --- a/Modules/_scproxy.c +++ b/Modules/_scproxy.c @@ -113,6 +113,7 @@ get_proxy_settings(PyObject* Py_UNUSED(mod), PyObject *Py_UNUSED(ignored)) } else { PyObject* t = cfstring_to_pystring(aString); if (!t) { + if (PyErr_Occurred()) goto error; PyTuple_SetItem(v, i, Py_NewRef(Py_None)); } else { PyTuple_SetItem(v, i, t); @@ -161,6 +162,7 @@ set_proxy(PyObject* proxies, const char* proto, CFDictionaryRef proxyDict, Py_DECREF(v); return r; } + if (PyErr_Occurred()) return -1; } }