library, GCC built-in atomic functions, or MSVC interlocked intrinsics.
* The ``errno``, ``md5``, ``resource``, ``winsound``, ``_ctypes_test``,
- ``_stat`` and ``_testimportmultiple`` C extensions are now built with the
- :ref:`limited C API <limited-c-api>`.
+ ``_scproxy``, ``_stat`` and ``_testimportmultiple`` C extensions are now
+ built with the :ref:`limited C API <limited-c-api>`.
(Contributed by Victor Stinner in :gh:`85283`.)
-The ``errno``, ``md5``, ``resource``, ``winsound``, ``_ctypes_test``, ``_stat``
-and ``_testimportmultiple`` C extensions are now built with the :ref:`limited C
-API <limited-c-api>`.
+The ``errno``, ``md5``, ``resource``, ``winsound``, ``_ctypes_test``,
+``_scproxy``, ``_stat`` and ``_testimportmultiple`` C extensions are now built
+with the :ref:`limited C API <limited-c-api>`.
Patch by Victor Stinner.
* Helper method for urllib to fetch the proxy configuration settings
* using the SystemConfiguration framework.
*/
+
+// Need limited C API version 3.13 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
+#define Py_LIMITED_API 0x030d0000
+
#include <Python.h>
#include <SystemConfiguration/SystemConfiguration.h>
s = CFStringGetCStringPtr(ref, kCFStringEncodingUTF8);
if (s) {
- return PyUnicode_DecodeUTF8(
- s, strlen(s), NULL);
+ return PyUnicode_DecodeUTF8(s, strlen(s), NULL);
} else {
CFIndex len = CFStringGetLength(ref);
PyMem_Free(buf);
return NULL;
} else {
- result = PyUnicode_DecodeUTF8(
- buf, strlen(buf), NULL);
+ result = PyUnicode_DecodeUTF8(buf, strlen(buf), NULL);
PyMem_Free(buf);
}
return result;
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,
aString = CFArrayGetValueAtIndex(anArray, i);
if (aString == NULL) {
- PyTuple_SetItem(v, i, Py_None);
- Py_INCREF(Py_None);
+ PyTuple_SetItem(v, i, Py_NewRef(Py_None));
} else {
PyObject* t = cfstring_to_pystring(aString);
if (!t) {
- PyTuple_SetItem(v, i, Py_None);
- Py_INCREF(Py_None);
+ PyTuple_SetItem(v, i, Py_NewRef(Py_None));
} else {
PyTuple_SetItem(v, i, t);
}
if (h) {
if (aNum) {
int32_t port = cfnum_to_int32(aNum);
- v = PyUnicode_FromFormat("http://%U:%ld",
- h, (long)port);
+ v = PyUnicode_FromFormat("http://%U:%ld", h, (long)port);
} else {
v = PyUnicode_FromFormat("http://%U", h);
}
Py_DECREF(h);
if (!v) return -1;
- r = PyDict_SetItemString(proxies, proto,
- v);
+ r = PyDict_SetItemString(proxies, proto, v);
Py_DECREF(v);
return r;
}