summaryrefslogtreecommitdiff
path: root/dev-python/blake3-py-c/files/blake3-py-c-0.3.1-backports.patch
blob: 0c36aaa5ff214634180e7b1cddace6b59f7288a8 (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
67
68
69
70
71
72
73
From 0d7526621087fd016d4ab5d34abfb35c715ec0cd Mon Sep 17 00:00:00 2001
From: Thomas Waldmann <tw@waldmann-edv.de>
Date: Tue, 29 Mar 2022 17:31:02 +0200
Subject: [PATCH] c_impl: compatibility fix for python < 3.10

---
 blake3module.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/blake3module.c b/blake3module.c
index f4160fb..0fce6ad 100644
--- a/blake3module.c
+++ b/blake3module.c
@@ -414,7 +414,8 @@ PyMODINIT_FUNC PyInit_blake3(void) {
     goto exit;
   }
 
-  if (PyModule_AddObjectRef(module, "blake3", (PyObject *)&Blake3Type) < 0) {
+  if (PyModule_AddObject(module, "blake3", (PyObject *)&Blake3Type) < 0) {
+    Py_DECREF((PyObject *)&Blake3Type);
     goto exit;
   }
 
From 52676a355eccfb0050b372cd36a14ab49878e8b3 Mon Sep 17 00:00:00 2001
From: Thomas Waldmann <tw@waldmann-edv.de>
Date: Tue, 29 Mar 2022 18:18:46 +0200
Subject: [PATCH] c_impl: apple silicon build fix, fixes #31

On Apple Silicon (M1 CPU), the platform.machine() call returns "arm64".
---
 setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index a159d8b..863c7ea 100644
--- a/setup.py
+++ b/setup.py
@@ -66,7 +66,7 @@ def targeting_x86_32():
 
 
 def is_aarch64():
-    return platform.machine().lower() == "aarch64"
+    return platform.machine().lower() in ("aarch64", "arm64")
 
 
 def force_intrinsics():
From 5eac8ae62d8f4e0a574164b73c42837ddc6ff356 Mon Sep 17 00:00:00 2001
From: Thomas Waldmann <tw@waldmann-edv.de>
Date: Tue, 29 Mar 2022 20:30:30 +0200
Subject: [PATCH] c_impl: fix usedforsecurity argument variable type, fixes #34

the python docs state that this must be int (not: bool).

as seen in #34, using the wrong type here seems to overflow the variable
and leads to a wrong value in max_threads, which leads to that strange
test failure.
---
 blake3module.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/blake3module.c b/blake3module.c
index 0fce6ad..a9562cf 100644
--- a/blake3module.c
+++ b/blake3module.c
@@ -53,7 +53,7 @@ static PyObject *Blake3_new(PyTypeObject *type, PyObject *args,
   Py_buffer key = {0};
   const char *derive_key_context = NULL;
   Py_ssize_t max_threads = 1;
-  bool usedforsecurity = true;
+  int usedforsecurity = 1;
 
   PyObject *ret = NULL;