Skip to content

Commit bda0b75

Browse files
committed
Add dummy implementations for C API functions PyState_Add/RemoveModule
1 parent 3f24a65 commit bda0b75

File tree

1 file changed

+33
-0
lines changed
  • graalpython/com.oracle.graal.python.cext/src

1 file changed

+33
-0
lines changed

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,36 @@ UPCALL_ID(PyState_FindModule)
6262
PyObject* PyState_FindModule(struct PyModuleDef* module) {
6363
return UPCALL_CEXT_O(_jls_PyState_FindModule, polyglot_from_string(module->m_name, SRC_CS));
6464
}
65+
66+
int PyState_AddModule(PyObject* module, struct PyModuleDef* def) {
67+
Py_ssize_t index;
68+
if (!def) {
69+
Py_FatalError("PyState_AddModule: Module Definition is NULL");
70+
return -1;
71+
}
72+
// TODO(fa): check if module was already added
73+
74+
if (def->m_slots) {
75+
PyErr_SetString(PyExc_SystemError,
76+
"PyState_AddModule called on module with slots");
77+
return -1;
78+
}
79+
80+
// TODO(fa): implement
81+
return 0;
82+
}
83+
84+
int PyState_RemoveModule(struct PyModuleDef* def) {
85+
Py_ssize_t index = def->m_base.m_index;
86+
if (def->m_slots) {
87+
PyErr_SetString(PyExc_SystemError,
88+
"PyState_RemoveModule called on module with slots");
89+
return -1;
90+
}
91+
if (index == 0) {
92+
Py_FatalError("PyState_RemoveModule: Module index invalid.");
93+
return -1;
94+
}
95+
// TODO(fa): implement
96+
return 0;
97+
}

0 commit comments

Comments
 (0)