Skip to content

Commit 2cbbde2

Browse files
committed
Add missing exception transformation
1 parent fbfa011 commit 2cbbde2

File tree

1 file changed

+54
-18
lines changed

1 file changed

+54
-18
lines changed

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

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -445,39 +445,75 @@ static int doGeneric(VirtualFrame frame, Object obj, Object typ,
445445
abstract static class PyObjectRichCompareNode extends PythonTernaryBuiltinNode {
446446

447447
@Specialization(guards = "op == 0")
448-
static Object op0(VirtualFrame frame, Object a, Object b, @SuppressWarnings("unused") int op,
449-
@Cached BinaryComparisonNode.LtNode compNode) {
450-
return compNode.executeObject(frame, a, b);
448+
Object op0(VirtualFrame frame, Object a, Object b, @SuppressWarnings("unused") int op,
449+
@Cached BinaryComparisonNode.LtNode compNode,
450+
@Shared("e") @Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
451+
try {
452+
return compNode.executeObject(frame, a, b);
453+
} catch (PException e) {
454+
transformExceptionToNativeNode.execute(frame, e);
455+
return getContext().getNativeNull();
456+
}
451457
}
452458

453459
@Specialization(guards = "op == 1")
454-
static Object op1(VirtualFrame frame, Object a, Object b, @SuppressWarnings("unused") int op,
455-
@Cached BinaryComparisonNode.LeNode compNode) {
456-
return compNode.executeObject(frame, a, b);
460+
Object op1(VirtualFrame frame, Object a, Object b, @SuppressWarnings("unused") int op,
461+
@Cached BinaryComparisonNode.LeNode compNode,
462+
@Shared("e") @Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
463+
try {
464+
return compNode.executeObject(frame, a, b);
465+
} catch (PException e) {
466+
transformExceptionToNativeNode.execute(frame, e);
467+
return getContext().getNativeNull();
468+
}
457469
}
458470

459471
@Specialization(guards = "op == 2")
460-
static Object op2(VirtualFrame frame, Object a, Object b, @SuppressWarnings("unused") int op,
461-
@Cached BinaryComparisonNode.EqNode compNode) {
462-
return compNode.executeObject(frame, a, b);
472+
Object op2(VirtualFrame frame, Object a, Object b, @SuppressWarnings("unused") int op,
473+
@Cached BinaryComparisonNode.EqNode compNode,
474+
@Shared("e") @Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
475+
try {
476+
return compNode.executeObject(frame, a, b);
477+
} catch (PException e) {
478+
transformExceptionToNativeNode.execute(frame, e);
479+
return getContext().getNativeNull();
480+
}
463481
}
464482

465483
@Specialization(guards = "op == 3")
466-
static Object op3(VirtualFrame frame, Object a, Object b, @SuppressWarnings("unused") int op,
467-
@Cached BinaryComparisonNode.NeNode compNode) {
468-
return compNode.executeObject(frame, a, b);
484+
Object op3(VirtualFrame frame, Object a, Object b, @SuppressWarnings("unused") int op,
485+
@Cached BinaryComparisonNode.NeNode compNode,
486+
@Shared("e") @Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
487+
try {
488+
return compNode.executeObject(frame, a, b);
489+
} catch (PException e) {
490+
transformExceptionToNativeNode.execute(frame, e);
491+
return getContext().getNativeNull();
492+
}
469493
}
470494

471495
@Specialization(guards = "op == 4")
472-
static Object op4(VirtualFrame frame, Object a, Object b, @SuppressWarnings("unused") int op,
473-
@Cached BinaryComparisonNode.GtNode compNode) {
474-
return compNode.executeObject(frame, a, b);
496+
Object op4(VirtualFrame frame, Object a, Object b, @SuppressWarnings("unused") int op,
497+
@Cached BinaryComparisonNode.GtNode compNode,
498+
@Shared("e") @Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
499+
try {
500+
return compNode.executeObject(frame, a, b);
501+
} catch (PException e) {
502+
transformExceptionToNativeNode.execute(frame, e);
503+
return getContext().getNativeNull();
504+
}
475505
}
476506

477507
@Specialization(guards = "op == 5")
478-
static Object op5(VirtualFrame frame, Object a, Object b, @SuppressWarnings("unused") int op,
479-
@Cached BinaryComparisonNode.GeNode compNode) {
480-
return compNode.executeObject(frame, a, b);
508+
Object op5(VirtualFrame frame, Object a, Object b, @SuppressWarnings("unused") int op,
509+
@Cached BinaryComparisonNode.GeNode compNode,
510+
@Shared("e") @Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
511+
try {
512+
return compNode.executeObject(frame, a, b);
513+
} catch (PException e) {
514+
transformExceptionToNativeNode.execute(frame, e);
515+
return getContext().getNativeNull();
516+
}
481517
}
482518
}
483519

0 commit comments

Comments
 (0)