gh-159739: Propagate macOS proxy conversion errors (#159750) Propagate Python exceptions from Core Foundation string conversion instead of returning a result with an exception set.
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 0000000..0e29daa --- /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 e9170f2..9416319 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; } }