File tree Expand file tree Collapse file tree 1 file changed +9
-16
lines changed Expand file tree Collapse file tree 1 file changed +9
-16
lines changed Original file line number Diff line number Diff line change 1
1
# Interoperability API
2
2
3
3
The interopability API consists of functions for converting
4
- ` PyObject * ` to ` PyRef ` , and vice versa
4
+ ` PyObject * ` to ` PyRef ` , and vice versa.
5
+ These functions are for internal use, so do not take a ` PyContext ` .
5
6
6
7
## Converting ` PyObject * ` to ` PyRef `
7
8
@@ -42,9 +43,8 @@ PyRef PyApi_Interop_FromObjectUnsafe_C(PyObject *obj)
42
43
return (PyRef) { obj };
43
44
}
44
45
45
- int PyApi_Interop_FromObject_C(PyObject *obj, PyRef *result )
46
+ PyRef PyApi_Interop_FromObject_C(PyObject *obj, PyExceptionRef *exc )
46
47
{
47
- int kind;
48
48
if (PyErr_Occurred()) {
49
49
PyObject *exception = get_normalized_exception();
50
50
if (object != NULL) {
@@ -56,12 +56,10 @@ int PyApi_Interop_FromObject_C(PyObject *obj, PyRef *result)
56
56
PyException_SetCause(new_exception, exception);
57
57
Py_DECREF(exception);
58
58
Py_DECREF(obj);
59
- obj = new_exception;
59
+ exception = new_exception;
60
60
}
61
- else {
62
- obj = exception;
63
- }
64
- kind = ERROR;
61
+ *exc = PyApi_Interop_FromException(exception);
62
+ return PyRef_INVALID;
65
63
}
66
64
else {
67
65
if (obj == NULL) {
@@ -70,16 +68,11 @@ int PyApi_Interop_FromObject_C(PyObject *obj, PyRef *result)
70
68
PyExc_SystemError,
71
69
"value is NULL without setting an exception"
72
70
);
73
- obj = exception;
74
- kind = ERROR;
75
- }
76
- else {
77
- *result = obj;
78
- kind = SUCCESS;
71
+ *exc = PyApi_Interop_FromException(exception);
72
+ return PyRef_INVALID;
79
73
}
80
74
}
81
- *result = PyApi_Interop_FromObjectUnsafe(obj);
82
- return kind;
75
+ return PyApi_Interop_FromObjectUnsafe(obj);
83
76
}
84
77
```
85
78
You can’t perform that action at this time.
0 commit comments