Skip to content

Commit b4ea386

Browse files
committed
Inherit tp_iter and tp_iternext
1 parent 4334b02 commit b4ea386

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ static void inherit_slots(PyTypeObject *type, PyTypeObject *base) {
343343
}
344344
/* COPYSLOT(tp_call); */
345345
}
346+
{
347+
COPYSLOT(tp_iter);
348+
COPYSLOT(tp_iternext);
349+
}
346350

347351
if ((type->tp_flags & Py_TPFLAGS_HAVE_FINALIZE) &&
348352
(base->tp_flags & Py_TPFLAGS_HAVE_FINALIZE)) {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
import static com.oracle.graal.python.nodes.SpecialMethodNames.__GETATTRIBUTE__;
7272
import static com.oracle.graal.python.nodes.SpecialMethodNames.__HASH__;
7373
import static com.oracle.graal.python.nodes.SpecialMethodNames.__INIT__;
74+
import static com.oracle.graal.python.nodes.SpecialMethodNames.__ITER__;
7475
import static com.oracle.graal.python.nodes.SpecialMethodNames.__NEW__;
7576
import static com.oracle.graal.python.nodes.SpecialMethodNames.__NEXT__;
7677
import static com.oracle.graal.python.nodes.SpecialMethodNames.__REPR__;
@@ -666,6 +667,13 @@ static Object doTpSetattro(PythonManagedClass object, @SuppressWarnings("unused"
666667
return PyProcsWrapper.createSetAttrWrapper(lookupAttrNode.execute(object, __SETATTR__));
667668
}
668669

670+
@Specialization(guards = "eq(TP_ITER, key)")
671+
static Object doTpIter(PythonManagedClass object, @SuppressWarnings("unused") PythonNativeWrapper nativeWrapper, @SuppressWarnings("unused") String key,
672+
@Cached LookupAttributeInMRONode.Dynamic lookupAttrNode,
673+
@Shared("toSulongNode") @Cached ToSulongNode toSulongNode) {
674+
return toSulongNode.execute(lookupAttrNode.execute(object, __ITER__));
675+
}
676+
669677
@Specialization(guards = "eq(TP_ITERNEXT, key)")
670678
static Object doTpIternext(PythonManagedClass object, @SuppressWarnings("unused") PythonNativeWrapper nativeWrapper, @SuppressWarnings("unused") String key,
671679
@Cached LookupAttributeInMRONode.Dynamic lookupAttrNode,

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
@@ -96,6 +96,7 @@ public enum NativeMember {
9696
TP_SETATTR("tp_setattr"),
9797
TP_GETATTRO("tp_getattro"),
9898
TP_SETATTRO("tp_setattro"),
99+
TP_ITER("tp_iter"),
99100
TP_ITERNEXT("tp_iternext"),
100101
TP_NEW("tp_new"),
101102
TP_INIT("tp_init"),

0 commit comments

Comments
 (0)