Resolves: #1890442 - make the code compile against python-3.10.0a1

This commit is contained in:
Kamil Dudka 2020-10-27 01:39:17 +01:00
parent 5dbaefcc9a
commit 2492f5a67e
2 changed files with 63 additions and 1 deletions

View File

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

View File

@ -16,7 +16,7 @@
Name: python-%{modname}
Version: 7.43.0.6
Release: 1%{?dist}
Release: 2%{?dist}
Summary: A Python interface to libcurl
License: LGPLv2+ or MIT
@ -25,6 +25,9 @@ URL: http://pycurl.sourceforge.net/
# Source0: https://dl.bintray.com/pycurl/pycurl/pycurl-%%{version}.tar.gz
Source0: https://github.com/pycurl/pycurl/archive/REL_7_43_0_6.tar.gz#/pycurl-%{version}.tar.gz
# make the code compile against python-3.10.0a1 (#1890442)
Patch1: 0001-python-pycurl-7.43.0.6-python-3.10.patch
# drop link-time vs. run-time TLS backend check (#1446850)
Patch2: 0002-python-pycurl-7.43.0-tls-backend.patch
@ -166,6 +169,9 @@ rm -fv tests/fake-curl/libcurl/*.so
%endif
%changelog
* Tue Oct 27 2020 Kamil Dudka <kdudka@redhat.com> - 7.43.0.6-2
- make the code compile against python-3.10.0a1 (#1890442)
* Thu Sep 03 2020 Kamil Dudka <kdudka@redhat.com> - 7.43.0.6-1
- update to 7.43.0.6