Skip to content

Commit 0ff8b43

Browse files
committed
Replace error marker by native NULL.
1 parent 8b862ba commit 0ff8b43

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

graalpython/com.oracle.graal.python.cext/src/capi.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ static void initialize_globals() {
168168
// error marker
169169
void *jerrormarker = UPCALL_CEXT_PTR(polyglot_from_string("Py_ErrorHandler", SRC_CS));
170170
truffle_assign_managed(&marker_struct, jerrormarker);
171+
172+
// register native NULL
173+
polyglot_invoke(PY_TRUFFLE_CEXT, polyglot_from_string("PyTruffle_Register_NULL", SRC_CS), NULL);
171174
}
172175

173176
static void initialize_bufferprocs() {
@@ -187,7 +190,7 @@ static void initialize_capi() {
187190

188191
__attribute__((always_inline))
189192
inline void* handle_exception(void* val) {
190-
return val == ERROR_MARKER ? NULL : val;
193+
return val;
191194
}
192195

193196
// Heuristic to test if some value is a pointer object

graalpython/lib-graalpython/python_cext.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141
import sys
4242
import python_cext
4343

44+
native_null = None
4445

45-
def may_raise(error_result=error_handler):
46+
def may_raise(error_result=native_null):
4647
if isinstance(error_result, type(may_raise)):
4748
# direct annotation
4849
return may_raise(error_handler)(error_result)
@@ -52,6 +53,11 @@ def decorator(fun):
5253
return decorator
5354

5455

56+
def PyTruffle_Register_NULL(object):
57+
global native_null
58+
native_null = object
59+
60+
5561
def Py_ErrorHandler():
5662
return to_sulong(error_handler)
5763

mx.graalpython/mx_graalpython_bench_param.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
'special-len': ITER_10 + ['5'],
9191
'member_access': ITER_10 + ['5'],
9292
'c_member_access': ITER_25 + ['5'],
93+
'cpyext/c-list-iterating-obj': ITER_15 + ['10000000']
9394
}
9495

9596

0 commit comments

Comments
 (0)