Skip to content

Commit 3769ed1

Browse files
committed
Expose PyMethodDef.m_module
1 parent 2e9537b commit 3769ed1

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import static com.oracle.graal.python.nodes.SpecialAttributeNames.__BASICSIZE__;
6767
import static com.oracle.graal.python.nodes.SpecialAttributeNames.__DICTOFFSET__;
6868
import static com.oracle.graal.python.nodes.SpecialAttributeNames.__ITEMSIZE__;
69+
import static com.oracle.graal.python.nodes.SpecialAttributeNames.__MODULE__;
6970
import static com.oracle.graal.python.nodes.SpecialAttributeNames.__WEAKLISTOFFSET__;
7071
import static com.oracle.graal.python.nodes.SpecialMethodNames.RICHCMP;
7172
import static com.oracle.graal.python.nodes.SpecialMethodNames.__CALL__;
@@ -152,6 +153,7 @@
152153
import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetTypeFlagsNode;
153154
import com.oracle.graal.python.lib.PyNumberAsSizeNode;
154155
import com.oracle.graal.python.lib.PyObjectGetAttr;
156+
import com.oracle.graal.python.lib.PyObjectLookupAttr;
155157
import com.oracle.graal.python.lib.PyObjectSizeNode;
156158
import com.oracle.graal.python.nodes.ErrorMessages;
157159
import com.oracle.graal.python.nodes.PGuards;
@@ -1068,6 +1070,14 @@ static Object doPyCFunctionObjectMMl(PythonObject object, @SuppressWarnings("unu
10681070
return new PyMethodDefWrapper(object);
10691071
}
10701072

1073+
@Specialization(guards = {"eq(M_MODULE, key)", "isAnyFunctionObject(object)"})
1074+
static Object doPyCFunctionObjectMModule(Object object, @SuppressWarnings("unused") PythonNativeWrapper nativeWrapper, @SuppressWarnings("unused") String key,
1075+
@Cached PyObjectLookupAttr lookup,
1076+
@Cached ToSulongNode toSulongNode) {
1077+
Object module = lookup.execute(null, object, __MODULE__);
1078+
return toSulongNode.execute(module != PNone.NO_VALUE ? module : PythonContext.get(toSulongNode).getNativeNull());
1079+
}
1080+
10711081
@Specialization(guards = "eq(M_SELF, key)")
10721082
static Object doPyCFunctionObjectMSelf(PBuiltinMethod object, @SuppressWarnings("unused") PythonNativeWrapper nativeWrapper, @SuppressWarnings("unused") String key,
10731083
@Cached ToSulongNode toSulongNode) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ public enum NativeMember {
233233
// PyCFunctionObject
234234
M_ML("m_ml"),
235235
M_SELF("m_self"),
236+
M_MODULE("m_module"),
236237

237238
// PyDateTime_Date
238239
DATETIME_DATA("data"),

0 commit comments

Comments
 (0)