Skip to content

Commit b3eea77

Browse files
committed
Implement C API function '_PyDict_Pop'
1 parent e084fcd commit b3eea77

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ int _PyDict_Next(PyObject *d, Py_ssize_t *ppos, PyObject **pkey, PyObject **pval
131131

132132
}
133133

134+
UPCALL_ID(PyDict_Pop);
135+
PyObject *
136+
_PyDict_Pop(PyObject *dict, PyObject *key, PyObject *deflt)
137+
{
138+
if (deflt) {
139+
return UPCALL_CEXT_O(_jls_PyDict_Pop, native_to_java(dict), native_to_java(key), native_to_java(deflt));
140+
}
141+
return UPCALL_CEXT_O(_jls_PyDict_Pop, native_to_java(dict), native_to_java(key));
142+
}
143+
134144
UPCALL_ID(PyDict_Size);
135145
Py_ssize_t PyDict_Size(PyObject *d) {
136146
return UPCALL_CEXT_L(_jls_PyDict_Size, native_to_java(d));

graalpython/lib-graalpython/python_cext.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ def PyDict_Next(dictObj, pos):
146146
return native_null
147147

148148

149+
@may_raise
150+
def PyDict_Pop(dictObj, *args):
151+
return dictObj.pop(*args)
152+
153+
149154
@may_raise(-1)
150155
def PyDict_Size(dictObj):
151156
if not isinstance(dictObj, dict):

0 commit comments

Comments
 (0)