Skip to content

Commit e30564b

Browse files
committed
Handle PyCFunctionWrapper in CreateFunctionNode
1 parent 9ca42b3 commit e30564b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiGuards.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -49,7 +49,7 @@ public static boolean isPrimitiveNativeWrapper(Object object) {
4949
}
5050

5151
public static boolean isNativeWrapper(Object object) {
52-
return object instanceof PythonNativeWrapper;
52+
return object instanceof PythonNativeWrapper || object instanceof PyCFunctionWrapper;
5353
}
5454

5555
public static boolean isNativeNull(Object object) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,16 @@ static Object doPythonCallable(TruffleString name, PythonNativeWrapper callable,
19571957
return function != null ? function : managedCallable;
19581958
}
19591959

1960+
@Specialization
1961+
@TruffleBoundary
1962+
static PBuiltinFunction doPyCFunctionWrapper(TruffleString name, PyCFunctionWrapper wrapper, int signature, Object type, int flags) {
1963+
Object delegate = wrapper.getDelegate();
1964+
assert !(delegate instanceof PythonAbstractObject);
1965+
PythonContext context = PythonContext.get(null);
1966+
PythonLanguage language = context.getLanguage();
1967+
return PExternalFunctionWrapper.createWrapperFunction(name, delegate, type, flags, signature, language, context.factory(), false);
1968+
}
1969+
19601970
@Specialization(guards = {"!isNativeWrapper(callable)"})
19611971
@TruffleBoundary
19621972
static Object doNativeCallableWithWrapper(TruffleString name, Object callable, int signature, Object type, int flags,

0 commit comments

Comments
 (0)