8000 Merge pull request #20 from markshannon/clarify-abi · markshannon/New-C-API-for-Python@9b1189e · GitHub
[go: up one dir, main page]

Skip to content

Commit 9b1189e

Browse files
authored
Merge pull request #20 from markshannon/clarify-abi
Clarify ABI
2 parents 6886b5f + c900ed2 commit 9b1189e

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

Interop.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Interoperability API
22

33
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`.
56

67
## Converting `PyObject *` to `PyRef`
78

@@ -42,9 +43,8 @@ PyRef PyApi_Interop_FromObjectUnsafe_C(PyObject *obj)
4243
return (PyRef) { obj };
4344
}
4445
45-
int PyApi_Interop_FromObject_C(PyObject *obj, PyRef *result)
46+
PyRef PyApi_Interop_FromObject_C(PyObject *obj, PyExceptionRef *exc)
4647
{
47-
int kind;
4848
if (PyErr_Occurred()) {
4949
PyObject *exception = get_normalized_exception();
5050
if (object != NULL) {
@@ -56,12 +56,10 @@ int PyApi_Interop_FromObject_C(PyObject *obj, PyRef *result)
5656
PyException_SetCause(new_exception, exception);
5757
Py_DECREF(exception);
5858
Py_DECREF(obj);
59-
obj = new_exception;
59+
exception = new_exception;
6060
}
61-
else {
62-
obj = exception;
63-
}
64-
kind = ERROR;
61+
*exc = PyApi_Interop_FromException(exception);
62+
return PyRef_INVALID;
6563
}
6664
else {
6765
if (obj == NULL) {
@@ -70,16 +68,11 @@ int PyApi_Interop_FromObject_C(PyObject *obj, PyRef *result)
7068
PyExc_SystemError,
7169
"value is NULL without setting an exception"
7270
);
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;
7973
}
8074
}
81-
*result = PyApi_Interop_FromObjectUnsafe(obj);
82-
return kind;
75+
return PyApi_Interop_FromObjectUnsafe(obj);
8376
}
8477
```
8578

0 commit comments

Comments
 (0)
0