Skip to content

Commit ca24e0c

Browse files
committed
never find modules with slots or 0 index, like cpython
1 parent 6a95c2c commit ca24e0c

File tree

1 file changed

+8
-1
lines changed
  • graalpython/com.oracle.graal.python.cext/src

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,14 @@ PyThreadState* PyGILState_GetThisThreadState(void) {
8181
typedef PyObject* (*find_module_fun_t)(long index);
8282
UPCALL_TYPED_ID(PyState_FindModule, find_module_fun_t);
8383
PyObject* PyState_FindModule(struct PyModuleDef* module) {
84-
return _jls_PyState_FindModule(module->m_base.m_index);
84+
Py_ssize_t index = module->m_base.m_index;
85+
if (module->m_slots) {
86+
return NULL;
87+
} else if (index == 0) {
88+
return NULL;
89+
} else {
90+
return _jls_PyState_FindModule(index);
91+
}
8592
}
8693

8794
int PyState_AddModule(PyObject* module, struct PyModuleDef* def) {

0 commit comments

Comments
 (0)