From d2d784bd0cbeb00a3fa1830296e58b0b4d0c7f85 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sat, 26 Aug 2023 18:33:23 +0200 Subject: [PATCH 1/2] gh-85283: _scproxy uses the limited C API The _scproxy (macOS) C extension is now built with the limited C API. --- .../next/C API/2023-08-28-17-58-46.gh-issue-85283.-4lp73.rst | 2 ++ Modules/_scproxy.c | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 Misc/NEWS.d/next/C API/2023-08-28-17-58-46.gh-issue-85283.-4lp73.rst diff --git a/Misc/NEWS.d/next/C API/2023-08-28-17-58-46.gh-issue-85283.-4lp73.rst b/Misc/NEWS.d/next/C API/2023-08-28-17-58-46.gh-issue-85283.-4lp73.rst new file mode 100644 index 00000000000000..ae756295de27f7 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2023-08-28-17-58-46.gh-issue-85283.-4lp73.rst @@ -0,0 +1,2 @@ +The ``_scproxy`` (macOS) C extension is now built with the :ref:`limited C API +`. Patch by Victor Stinner. diff --git a/Modules/_scproxy.c b/Modules/_scproxy.c index 0df0324df55f7d..3582cd4d848b0a 100644 --- a/Modules/_scproxy.c +++ b/Modules/_scproxy.c @@ -2,6 +2,8 @@ * Helper method for urllib to fetch the proxy configuration settings * using the SystemConfiguration framework. */ +#define Py_LIMITED_API 0x030d0000 + #include #include From dbc373aa3fdf35cb71a99d030453dedfc3185243 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 28 Aug 2023 18:25:15 +0200 Subject: [PATCH 2/2] Replace Py_SETREF(v, NULL) with Py_CLEAR(v) Py_SETREF() is not part of the limited C API --- Modules/_scproxy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_scproxy.c b/Modules/_scproxy.c index 3582cd4d848b0a..16b70079fe6a87 100644 --- a/Modules/_scproxy.c +++ b/Modules/_scproxy.c @@ -86,7 +86,7 @@ get_proxy_settings(PyObject* Py_UNUSED(mod), PyObject *Py_UNUSED(ignored)) if (v == NULL) goto error; r = PyDict_SetItemString(result, "exclude_simple", v); - Py_SETREF(v, NULL); + Py_CLEAR(v); if (r == -1) goto error; anArray = CFDictionaryGetValue(proxyDict,