Skip to content

Commit 533216b

Browse files
committed
Implement PyInterpreterState_GetDict
1 parent d188c80 commit 533216b

File tree

2 files changed

+17
-1
lines changed
  • graalpython
    • com.oracle.graal.python.cext/src
    • com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi

2 files changed

+17
-1
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,19 @@ PyGILState_Release(PyGILState_STATE oldstate)
190190
}
191191
}
192192
}
193+
194+
// GraalPy change: We don't have subinterpreters at the moment, so store the dict into a global object
195+
static PyObject* interpreter_dict;
196+
197+
PyObject *
198+
PyInterpreterState_GetDict(PyInterpreterState *interp)
199+
{
200+
if (interpreter_dict == NULL) {
201+
interpreter_dict = PyDict_New();
202+
if (interpreter_dict == NULL) {
203+
PyErr_Clear();
204+
}
205+
}
206+
/* Returning NULL means no per-interpreter dict is available. */
207+
return interpreter_dict;
208+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ public final class CApiFunction {
291291
@CApiBuiltin(name = "PyImport_AddModuleObject", ret = PyObject, args = {PyObject}, call = CImpl)
292292
@CApiBuiltin(name = "PyImport_ImportModuleLevel", ret = PyObject, args = {ConstCharPtrAsTruffleString, PyObject, PyObject, PyObject, Int}, call = CImpl)
293293
@CApiBuiltin(name = "PyInstanceMethod_Function", ret = PyObject, args = {PyObject}, call = CImpl)
294+
@CApiBuiltin(name = "PyInterpreterState_GetDict", ret = PyObject, args = {PyInterpreterState}, call = CImpl)
294295
@CApiBuiltin(name = "PyInterpreterState_GetID", ret = INT64_T, args = {PyInterpreterState}, call = CImpl)
295296
@CApiBuiltin(name = "PyInterpreterState_GetIDFromThreadState", ret = INT64_T, args = {PyThreadState}, call = CImpl)
296297
@CApiBuiltin(name = "PyInterpreterState_Main", ret = PyInterpreterState, args = {}, call = CImpl)
@@ -773,7 +774,6 @@ public final class CApiFunction {
773774
@CApiBuiltin(name = "PyInterpreterState_Clear", ret = Void, args = {PyInterpreterState}, call = NotImplemented)
774775
@CApiBuiltin(name = "PyInterpreterState_Delete", ret = Void, args = {PyInterpreterState}, call = NotImplemented)
775776
@CApiBuiltin(name = "PyInterpreterState_Get", ret = PyInterpreterState, args = {}, call = NotImplemented)
776-
@CApiBuiltin(name = "PyInterpreterState_GetDict", ret = PyObject, args = {PyInterpreterState}, call = NotImplemented)
777777
@CApiBuiltin(name = "PyInterpreterState_Head", ret = PyInterpreterState, args = {}, call = NotImplemented)
778778
@CApiBuiltin(name = "PyInterpreterState_New", ret = PyInterpreterState, args = {}, call = NotImplemented)
779779
@CApiBuiltin(name = "PyInterpreterState_Next", ret = PyInterpreterState, args = {PyInterpreterState}, call = NotImplemented)

0 commit comments

Comments
 (0)