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

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