Skip to content

Commit 183249e

Browse files
committed
add a couple of null checks
1 parent 76a3614 commit 183249e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
PyTypeObject PyCapsule_Type = PY_TRUFFLE_TYPE("PyCapsule", &PyType_Type, 0);
4242

4343
PyObject* PyCapsule_New(void *pointer, const char *name, PyCapsule_Destructor destructor) {
44-
return (PyObject *)polyglot_as_PyCapsule(to_sulong(polyglot_invoke(PY_TRUFFLE_CEXT, "PyCapsule", polyglot_from_string(name, "ascii"), pointer, destructor)));
44+
return (PyObject *)polyglot_as_PyCapsule(to_sulong(polyglot_invoke(PY_TRUFFLE_CEXT, "PyCapsule", name ? polyglot_from_string(name, "ascii") : to_java(Py_None), pointer, destructor)));
4545
}
4646

4747
void* PyCapsule_GetContext(PyObject *o) {

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@ int PyType_Ready(PyTypeObject* cls) {
211211
}
212212

213213
PyTypeObject* javacls = truffle_invoke(PY_TRUFFLE_CEXT,
214-
"PyType_Ready",
215-
// no conversion of cls here, because we
216-
// store this into the PyTypeObject
217-
cls,
218-
to_java_type(metaclass),
219-
to_java_type(base),
220-
truffle_read_string(cls->tp_name),
221-
truffle_read_string(cls->tp_doc));
214+
"PyType_Ready",
215+
// no conversion of cls here, because we
216+
// store this into the PyTypeObject
217+
cls,
218+
to_java_type(metaclass),
219+
to_java_type(base),
220+
truffle_read_string(cls->tp_name),
221+
truffle_read_string(cls->tp_doc ? cls->tp_doc : ""));
222222
if (polyglot_is_value(javacls)) {
223223
javacls = polyglot_as__typeobject(javacls);
224224
}
@@ -263,7 +263,7 @@ int PyType_Ready(PyTypeObject* cls) {
263263
member.offset,
264264
// TODO: support other flags
265265
((member.flags & READONLY) == 0) ? Py_True : Py_False,
266-
truffle_read_string(member.doc));
266+
truffle_read_string(member.doc ? member.doc : ""));
267267
member = members[++i];
268268
}
269269
}

0 commit comments

Comments
 (0)