Skip to content

Commit e43231d

Browse files
committed
add dummy impls for _PyErr_ChainExceptions and _PyErr_FormatFromCause
1 parent 0dd950b commit e43231d

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,17 @@ int PyErr_WarnExplicitFormat(PyObject *category,
176176
return ret;
177177
}
178178

179+
void _PyErr_ChainExceptions(PyObject* a, PyObject* b, PyObject* c) {
180+
// empty dummy implementation
181+
}
182+
183+
PyObject* _PyErr_FormatFromCause(PyObject *exception, const char *format, ...) {
184+
// dummy implementation that ignores the cause
185+
va_list args;
186+
va_start(args, format);
187+
PyObject* formatted_msg = PyUnicode_FromFormatV(format, args);
188+
va_end(args);
189+
Graal_PyTruffleErr_CreateAndSetException(exception, formatted_msg);
190+
return NULL;
191+
}
179192

graalpython/com.oracle.graal.python.jni/src/capi_forwards.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4995,15 +4995,9 @@ void (*__target___PyErr_BadInternalCall)(const char*, int) = NULL;
49954995
PyAPI_FUNC(void) _PyErr_BadInternalCall(const char* a, int b) {
49964996
__target___PyErr_BadInternalCall(a, b);
49974997
}
4998-
PyAPI_FUNC(void) _PyErr_ChainExceptions(PyObject* a, PyObject* b, PyObject* c) {
4999-
unimplemented("_PyErr_ChainExceptions"); exit(-1);
5000-
}
50014998
PyAPI_FUNC(int) _PyErr_CheckSignals() {
50024999
unimplemented("_PyErr_CheckSignals"); exit(-1);
50035000
}
5004-
PyAPI_FUNC(PyObject*) _PyErr_FormatFromCause(PyObject* a, const char* b, ...) {
5005-
unimplemented("_PyErr_FormatFromCause"); exit(-1);
5006-
}
50075001
PyAPI_FUNC(void) _PyErr_GetExcInfo(PyThreadState* a, PyObject** b, PyObject** c, PyObject** d) {
50085002
unimplemented("_PyErr_GetExcInfo"); exit(-1);
50095003
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ public final class CApiFunction {
373373
@CApiBuiltin(name = "PyByteArray_Size", ret = Py_ssize_t, args = {PyObject}, call = CImpl)
374374
@CApiBuiltin(name = "PyGILState_Ensure", ret = PY_GIL_STATE_STATE, args = {}, acquiresGIL = false, call = CImpl)
375375
@CApiBuiltin(name = "PyGILState_Release", ret = Void, args = {PY_GIL_STATE_STATE}, acquiresGIL = false, call = CImpl)
376+
@CApiBuiltin(name = "_PyErr_ChainExceptions", ret = Void, args = {PyObject, PyObject, PyObject}, call = CImpl)
377+
@CApiBuiltin(name = "_PyErr_FormatFromCause", ret = PyObject, args = {PyObject, ConstCharPtrAsTruffleString, VARARGS}, call = CImpl)
376378

377379
/*
378380
* Functions that are implemented in C code that needs to run on Sulong:
@@ -782,9 +784,7 @@ public final class CApiFunction {
782784
@CApiBuiltin(name = "_PyDict_SizeOf", ret = Py_ssize_t, args = {PYDICTOBJECT_PTR}, call = NotImplemented)
783785
@CApiBuiltin(name = "_PyDictView_Intersect", ret = PyObject, args = {PyObject, PyObject}, call = NotImplemented)
784786
@CApiBuiltin(name = "_PyDictView_New", ret = PyObject, args = {PyObject, PyTypeObject}, call = NotImplemented)
785-
@CApiBuiltin(name = "_PyErr_ChainExceptions", ret = Void, args = {PyObject, PyObject, PyObject}, call = NotImplemented)
786787
@CApiBuiltin(name = "_PyErr_CheckSignals", ret = Int, args = {}, call = NotImplemented)
787-
@CApiBuiltin(name = "_PyErr_FormatFromCause", ret = PyObject, args = {PyObject, ConstCharPtrAsTruffleString, VARARGS}, call = NotImplemented)
788788
@CApiBuiltin(name = "_PyErr_GetExcInfo", ret = Void, args = {PyThreadState, PyObjectPtr, PyObjectPtr, PyObjectPtr}, call = NotImplemented)
789789
@CApiBuiltin(name = "_PyErr_GetTopmostException", ret = _PYERR_STACKITEM_PTR, args = {PyThreadState}, call = NotImplemented)
790790
@CApiBuiltin(name = "_PyErr_ProgramDecodedTextObject", ret = PyObject, args = {PyObject, Int, ConstCharPtr}, call = NotImplemented)

0 commit comments

Comments
 (0)