Blame SOURCES/0001-python-pycurl-7.43.0.6-python-3.10.patch

1178d8
From b3a1ff559c28f71702248cae317fa83baaa086a0 Mon Sep 17 00:00:00 2001
1178d8
From: Kamil Dudka <kdudka@redhat.com>
1178d8
Date: Mon, 26 Oct 2020 17:26:23 +0100
1178d8
Subject: [PATCH] src/module.c: make the code compile against python-3.10.0a1
1178d8
1178d8
src/module.c:353:25: error: lvalue required as left operand of assignment
1178d8
  353 |     Py_TYPE(&Curl_Type) = &PyType_Type;
1178d8
      |                         ^
1178d8
src/module.c:354:30: error: lvalue required as left operand of assignment
1178d8
  354 |     Py_TYPE(&CurlMulti_Type) = &PyType_Type;
1178d8
      |                              ^
1178d8
src/module.c:355:30: error: lvalue required as left operand of assignment
1178d8
  355 |     Py_TYPE(&CurlShare_Type) = &PyType_Type;
1178d8
      |                              ^
1178d8
1178d8
Bug: https://bugzilla.redhat.com/1890442
1178d8
1178d8
Upstream-commit: c4036bdcb5dd01420a451cf02efac7c3fdf9e41f
1178d8
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
1178d8
---
1178d8
 src/module.c | 12 +++++++++---
1178d8
 1 file changed, 9 insertions(+), 3 deletions(-)
1178d8
1178d8
diff --git a/src/module.c b/src/module.c
1178d8
index 65e8c3a..9204ee0 100644
1178d8
--- a/src/module.c
1178d8
+++ b/src/module.c
1178d8
@@ -11,6 +11,12 @@
1178d8
 
1178d8
 #define PYCURL_VERSION_PREFIX "PycURL/" PYCURL_VERSION_STRING
1178d8
 
1178d8
+/* needed for compatibility with python < 3.10, as suggested at:
1178d8
+ * https://docs.python.org/3.10/whatsnew/3.10.html#id2 */
1178d8
+#if PY_VERSION_HEX < 0x030900A4
1178d8
+#  define Py_SET_TYPE(obj, type) ((Py_TYPE(obj) = (type)), (void)0)
1178d8
+#endif
1178d8
+
1178d8
 PYCURL_INTERNAL char *empty_keywords[] = { NULL };
1178d8
 
1178d8
 PYCURL_INTERNAL PyObject *bytesio = NULL;
1178d8
@@ -412,9 +418,9 @@ initpycurl(void)
1178d8
     p_Curl_Type = &Curl_Type;
1178d8
     p_CurlMulti_Type = &CurlMulti_Type;
1178d8
     p_CurlShare_Type = &CurlShare_Type;
1178d8
-    Py_TYPE(&Curl_Type) = &PyType_Type;
1178d8
-    Py_TYPE(&CurlMulti_Type) = &PyType_Type;
1178d8
-    Py_TYPE(&CurlShare_Type) = &PyType_Type;
1178d8
+    Py_SET_TYPE(&Curl_Type, &PyType_Type);
1178d8
+    Py_SET_TYPE(&CurlMulti_Type, &PyType_Type);
1178d8
+    Py_SET_TYPE(&CurlShare_Type, &PyType_Type);
1178d8
 
1178d8
     /* Create the module and add the functions */
1178d8
     if (PyType_Ready(&Curl_Type) < 0)
1178d8
-- 
1178d8
2.25.4
1178d8