summarylogtreecommitdiffstats
path: root/py11.patch
blob: 51ae6e67aee5b4a02dfba98b8aed6f1070261875 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
From 8bddcc27052017b5b9cb89c24dbfdf06737b0dd3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= <bjorn.forsman@gmail.com>
Date: Mon, 4 Jul 2022 09:22:32 +0200
Subject: [PATCH 1/2] core: fix building against python-3.10
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Specifically this build error:

  In file included from src/pyuv.c:8:
  src/handle.c: In function ‘resurrect_object’:
  src/handle.c:17:21: error: lvalue required as left operand of assignment
     17 |     Py_REFCNT(self) = refcnt;
        |                     ^

Fixes https://github.com/saghul/pyuv/issues/271.

Co-authored-by: @polkovnikov
---
 src/handle.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/handle.c b/src/handle.c
index fa308e26..c43b602e 100644
--- a/src/handle.c
+++ b/src/handle.c
@@ -14,7 +14,11 @@ resurrect_object(PyObject *self)
     Py_ssize_t refcnt = Py_REFCNT(self);
     ASSERT(Py_REFCNT(self) != 0);
     _Py_NewReference(self);
+#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 10
+    Py_SET_REFCNT(self, refcnt);
+#else
     Py_REFCNT(self) = refcnt;
+#endif
     /* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
      * we need to undo that. */
 #ifdef _Py_DEC_REFTOTAL

From 2a3d42d44c6315ebd73899a35118380d2d5979b5 Mon Sep 17 00:00:00 2001
From: Tommaso Caiazzi <tommasocaiazzi@gmail.com>
Date: Mon, 15 May 2023 18:48:01 +0200
Subject: [PATCH 2/2] build: fix building for Python3.11

Co-authored-by: Mariano Scazzariello <marianoscazzariello@gmail.com>
---
 src/common.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/common.c b/src/common.c
index ecac76ea..e6bf2935 100644
--- a/src/common.c
+++ b/src/common.c
@@ -39,7 +39,11 @@ pyuv_PyUnicode_EncodeFSDefault(PyObject *unicode)
         return PyUnicode_AsEncodedString(unicode, Py_FileSystemDefaultEncoding, "surrogateescape");
     else
 #endif
+    #if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 11
+        return PyUnicode_AsUTF8String(unicode);
+    #else
         return PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(unicode), PyUnicode_GET_SIZE(unicode), "surrogateescape");
+    #endif
 }