Skip to content

Commit 3be7837

Browse files
committed
Allow NULL argument to PyCapsule_SetName()
1 parent b6d7929 commit 3be7837

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextCapsuleBuiltins.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,21 @@ public int doit(PyCapsule o, TruffleString name,
368368
}
369369
}
370370

371+
@Specialization(guards = "isNoValue(name)")
372+
public int doit(PyCapsule o, @SuppressWarnings("unused") PNone name,
373+
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
374+
try {
375+
if (o.getPointer() == null) {
376+
throw raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_SetName");
377+
}
378+
o.setName(null);
379+
return 0;
380+
} catch (PException e) {
381+
transformExceptionToNativeNode.execute(e);
382+
return -1;
383+
}
384+
}
385+
371386
@Fallback
372387
public Object doit(VirtualFrame ignoredFrame, Object ignoredo, Object ignored) {
373388
try {

0 commit comments

Comments
 (0)