File: 0011-Comment-out-all-C-level-changes.patch

package info (click to toggle)
numba 0.56.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 23,672 kB
  • sloc: python: 183,651; ansic: 15,370; cpp: 2,259; javascript: 424; sh: 308; makefile: 174
file content (296 lines) | stat: -rw-r--r-- 12,101 bytes parent folder | download
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
From: esc <esc@users.noreply.github.com>
Origin: https://github.com/numba/numba/pull/8545
Date: Fri, 29 Jul 2022 14:06:26 +0200
Subject: Comment out all C-level changes

This will make Numba compile against the Python 3.11 code-base and
C-level API. Note that some of the Numba functionality may not be
available as a result.
---
 numba/_dispatcher.cpp    | 188 +++++++++++++++++++++++------------------------
 numba/_helperlib.c       |   8 +-
 numba/cpython/hashing.py |   2 +-
 3 files changed, 99 insertions(+), 99 deletions(-)

diff --git a/numba/_dispatcher.cpp b/numba/_dispatcher.cpp
index 5ffefb2..3f9b15d 100644
--- a/numba/_dispatcher.cpp
+++ b/numba/_dispatcher.cpp
@@ -31,7 +31,7 @@
  * trace_info structure to help make tracing more robust. See:
  * https://github.com/python/cpython/pull/24726
  */
-#if (PY_MAJOR_VERSION >= 3) && (PY_MINOR_VERSION >= 10)
+#if (PY_MAJOR_VERSION >= 3) && (PY_MINOR_VERSION == 10)
 
 /*
  * Code originally from:
@@ -102,7 +102,7 @@ call_trace(Py_tracefunc func, PyObject *obj,
     if (tstate->tracing)
         return 0;
     tstate->tracing++;
-    tstate->cframe->use_tracing = 0;
+    tstate->frame->tracing = 0;
     if (frame->f_lasti < 0) {
         frame->f_lineno = frame->f_code->co_firstlineno;
     }
@@ -112,7 +112,7 @@ call_trace(Py_tracefunc func, PyObject *obj,
     }
     result = func(obj, frame, what, arg);
     frame->f_lineno = 0;
-    tstate->cframe->use_tracing = ((tstate->c_tracefunc != NULL)
+    tstate->frame->tracing = ((tstate->c_tracefunc != NULL)
                            || (tstate->c_profilefunc != NULL));
     tstate->tracing--;
     return result;
@@ -188,92 +188,92 @@ else                                                            \
 
 #else
 
-/*
- * Code originally from:
- * https://github.com/python/cpython/blob/d5650a1738fe34f6e1db4af5f4c4edb7cae90a36/Python/ceval.c#L4242-L4257
- */
-static int
-call_trace(Py_tracefunc func, PyObject *obj,
-           PyThreadState *tstate, PyFrameObject *frame,
-           int what, PyObject *arg)
-{
-    int result;
-    if (tstate->tracing)
-        return 0;
-    tstate->tracing++;
-    tstate->use_tracing = 0;
-    result = func(obj, frame, what, arg);
-    tstate->use_tracing = ((tstate->c_tracefunc != NULL)
-                           || (tstate->c_profilefunc != NULL));
-    tstate->tracing--;
-    return result;
-}
-
-/*
- * Code originally from:
- * https://github.com/python/cpython/blob/d5650a1738fe34f6e1db4af5f4c4edb7cae90a36/Python/ceval.c#L4220-L4240
- */
-static int
-call_trace_protected(Py_tracefunc func, PyObject *obj,
-                     PyThreadState *tstate, PyFrameObject *frame,
-                     int what, PyObject *arg)
-{
-    PyObject *type, *value, *traceback;
-    int err;
-    PyErr_Fetch(&type, &value, &traceback);
-    err = call_trace(func, obj, tstate, frame, what, arg);
-    if (err == 0)
-    {
-        PyErr_Restore(type, value, traceback);
-        return 0;
-    }
-    else
-    {
-        Py_XDECREF(type);
-        Py_XDECREF(value);
-        Py_XDECREF(traceback);
-        return -1;
-    }
-}
-
-/*
- * Code originally from:
- * https://github.com/python/cpython/blob/d5650a1738fe34f6e1db4af5f4c4edb7cae90a36/Python/ceval.c#L4520-L4549
- * NOTE: The state test https://github.com/python/cpython/blob/d5650a1738fe34f6e1db4af5f4c4edb7cae90a36/Python/ceval.c#L4521
- * has been removed, it's dealt with in call_cfunc.
- */
-#define C_TRACE(x, call)                                        \
-if (call_trace(tstate->c_profilefunc, tstate->c_profileobj,     \
-               tstate, tstate->frame, PyTrace_CALL, cfunc))     \
-    x = NULL;                                                   \
-else                                                            \
-{                                                               \
-    x = call;                                                   \
-    if (tstate->c_profilefunc != NULL)                          \
-    {                                                           \
-        if (x == NULL)                                          \
-        {                                                       \
-            call_trace_protected(tstate->c_profilefunc,         \
-                                 tstate->c_profileobj,          \
-                                 tstate, tstate->frame,         \
-                                 PyTrace_RETURN, cfunc);        \
-            /* XXX should pass (type, value, tb) */             \
-        }                                                       \
-        else                                                    \
-        {                                                       \
-            if (call_trace(tstate->c_profilefunc,               \
-                           tstate->c_profileobj,                \
-                           tstate, tstate->frame,               \
-                           PyTrace_RETURN, cfunc))              \
-            {                                                   \
-                Py_DECREF(x);                                   \
-                x = NULL;                                       \
-            }                                                   \
-        }                                                       \
-    }                                                           \
-}
-
-
+// /*
+//  * Code originally from:
+//  * https://github.com/python/cpython/blob/d5650a1738fe34f6e1db4af5f4c4edb7cae90a36/Python/ceval.c#L4242-L4257
+//  */
+// static int
+// call_trace(Py_tracefunc func, PyObject *obj,
+//            PyThreadState *tstate, PyFrameObject *frame,
+//            int what, PyObject *arg)
+// {
+//     int result;
+//     if (tstate->tracing)
+//         return 0;
+//     tstate->tracing++;
+//     tstate->use_tracing = 0;
+//     result = func(obj, frame, what, arg);
+//     tstate->use_tracing = ((tstate->c_tracefunc != NULL)
+//                            || (tstate->c_profilefunc != NULL));
+//     tstate->tracing--;
+//     return result;
+// }
+// 
+// /*
+//  * Code originally from:
+//  * https://github.com/python/cpython/blob/d5650a1738fe34f6e1db4af5f4c4edb7cae90a36/Python/ceval.c#L4220-L4240
+//  */
+// static int
+// call_trace_protected(Py_tracefunc func, PyObject *obj,
+//                      PyThreadState *tstate, PyFrameObject *frame,
+//                      int what, PyObject *arg)
+// {
+//     PyObject *type, *value, *traceback;
+//     int err;
+//     PyErr_Fetch(&type, &value, &traceback);
+//     err = call_trace(func, obj, tstate, frame, what, arg);
+//     if (err == 0)
+//     {
+//         PyErr_Restore(type, value, traceback);
+//         return 0;
+//     }
+//     else
+//     {
+//         Py_XDECREF(type);
+//         Py_XDECREF(value);
+//         Py_XDECREF(traceback);
+//         return -1;
+//     }
+// }
+// 
+// /*
+//  * Code originally from:
+//  * https://github.com/python/cpython/blob/d5650a1738fe34f6e1db4af5f4c4edb7cae90a36/Python/ceval.c#L4520-L4549
+//  * NOTE: The state test https://github.com/python/cpython/blob/d5650a1738fe34f6e1db4af5f4c4edb7cae90a36/Python/ceval.c#L4521
+//  * has been removed, it's dealt with in call_cfunc.
+//  */
+// #define C_TRACE(x, call)                                        \
+// if (call_trace(tstate->c_profilefunc, tstate->c_profileobj,     \
+//                tstate, tstate->frame, PyTrace_CALL, cfunc))     \
+//     x = NULL;                                                   \
+// else                                                            \
+// {                                                               \
+//     x = call;                                                   \
+//     if (tstate->c_profilefunc != NULL)                          \
+//     {                                                           \
+//         if (x == NULL)                                          \
+//         {                                                       \
+//             call_trace_protected(tstate->c_profilefunc,         \
+//                                  tstate->c_profileobj,          \
+//                                  tstate, tstate->frame,         \
+//                                  PyTrace_RETURN, cfunc);        \
+//             /* XXX should pass (type, value, tb) */             \
+//         }                                                       \
+//         else                                                    \
+//         {                                                       \
+//             if (call_trace(tstate->c_profilefunc,               \
+//                            tstate->c_profileobj,                \
+//                            tstate, tstate->frame,               \
+//                            PyTrace_RETURN, cfunc))              \
+//             {                                                   \
+//                 Py_DECREF(x);                                   \
+//                 x = NULL;                                       \
+//             }                                                   \
+//         }                                                       \
+//     }                                                           \
+// }
+// 
+// 
 #endif
 
 typedef std::vector<Type> TypeTable;
@@ -562,7 +562,7 @@ call_cfunc(Dispatcher *self, PyObject *cfunc, PyObject *args, PyObject *kws, PyO
     fn = (PyCFunctionWithKeywords) PyCFunction_GET_FUNCTION(cfunc);
     tstate = PyThreadState_GET();
 
-#if (PY_MAJOR_VERSION >= 3) && (PY_MINOR_VERSION >= 10)
+#if (PY_MAJOR_VERSION >= 3) && (PY_MINOR_VERSION == 10)
     /*
      * On Python 3.10+ trace_info comes from somewhere up in PyFrameEval et al,
      * Numba doesn't have access to that so creates an equivalent struct and
@@ -583,7 +583,7 @@ call_cfunc(Dispatcher *self, PyObject *cfunc, PyObject *args, PyObject *kws, PyO
     /*
      * On Python prior to 3.10, tracing state is a member of the threadstate
      */
-    if (tstate->use_tracing && tstate->c_profilefunc)
+    if (tstate->tracing && tstate->c_profilefunc)
 #endif
     {
         /*
@@ -621,11 +621,11 @@ call_cfunc(Dispatcher *self, PyObject *cfunc, PyObject *args, PyObject *kws, PyO
         }
         /* Populate the 'fast locals' in `frame` */
         PyFrame_LocalsToFast(frame, 0);
-        tstate->frame = frame;
-        C_TRACE(result, fn(PyCFunction_GET_SELF(cfunc), args, kws));
+        //tstate->cframe = frame;
+        //C_TRACE(result, fn(PyCFunction_GET_SELF(cfunc), args, kws));
         /* write changes back to locals? */
         PyFrame_FastToLocals(frame);
-        tstate->frame = frame->f_back;
+        //tstate->frame = frame->f_back;
 
     error:
         Py_XDECREF(frame);
diff --git a/numba/_helperlib.c b/numba/_helperlib.c
index c1da224..705404d 100644
--- a/numba/_helperlib.c
+++ b/numba/_helperlib.c
@@ -819,7 +819,7 @@ static void traceback_add(const char *funcname, const char *filename, int lineno
     Py_DECREF(code);
     if (!frame)
         goto error;
-    frame->f_lineno = lineno;
+    //frame->f_lineno = lineno;
 
     PyErr_Restore(exc, val, tb);
     PyTraceBack_Here(frame);
@@ -872,9 +872,9 @@ int reraise_exc_is_none(void) {
 #else
     PyThreadState *tstate_exc = tstate;
 #endif
-    type = tstate_exc->exc_type;
-    value = tstate_exc->exc_value;
-    tb = tstate_exc->exc_traceback;
+    type = tstate->curexc_type;
+    value = tstate->curexc_value;
+    tb = tstate->curexc_traceback;
     if (type == Py_None) {
         PyErr_SetString(PyExc_RuntimeError,
                         "No active exception to reraise");
diff --git a/numba/cpython/hashing.py b/numba/cpython/hashing.py
index dcb71c9..ec71c7c 100644
--- a/numba/cpython/hashing.py
+++ b/numba/cpython/hashing.py
@@ -39,7 +39,7 @@ _PyHASH_MULTIPLIER = 0xf4243  # 1000003UL
 _PyHASH_IMAG = _PyHASH_MULTIPLIER
 _PyLong_SHIFT = sys.int_info.bits_per_digit
 _Py_HASH_CUTOFF = sys.hash_info.cutoff
-_Py_hashfunc_name = sys.hash_info.algorithm
+_Py_hashfunc_name = "siphash24"
 
 
 # hash(obj) is implemented by calling obj.__hash__()