Skip to content

Commit ca63486

Browse files
committed
Implement C API function PyObject_DelItem.
1 parent 678b424 commit ca63486

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,11 @@ int PyObject_SetItem(PyObject* obj, PyObject* key, PyObject* value) {
319319
return UPCALL_CEXT_I(_jls_PyObject_SetItem, native_to_java(obj), native_to_java(key), native_to_java(value));
320320
}
321321

322+
UPCALL_ID(PyObject_DelItem);
323+
int PyObject_DelItem(PyObject *o, PyObject *key) {
324+
return UPCALL_CEXT_I(_jls_PyObject_DelItem, native_to_java(o), native_to_java(key));
325+
}
326+
322327
PyObject* PyObject_Format(PyObject* obj, PyObject* spec) {
323328
return UPCALL_O(native_to_java(obj), polyglot_from_string("__format__", SRC_CS), native_to_java(spec));
324329
}

graalpython/lib-graalpython/python_cext.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,12 @@ def PyObject_GetItem(obj, key):
10371037
return obj[key]
10381038

10391039

1040+
@may_raise(-1)
1041+
def PyObject_DelItem(obj, key):
1042+
del obj[key]
1043+
return 0
1044+
1045+
10401046
@may_raise(1)
10411047
def PyObject_SetItem(obj, key, value):
10421048
obj[key] = value

0 commit comments

Comments
 (0)