Skip to content

Commit 59644c1

Browse files
committed
Fix handling NotImplemented in LengthNode
1 parent 3e5e565 commit 59644c1

File tree

1 file changed

+4
-4
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator

1 file changed

+4
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorNodes.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@ int length(VirtualFrame frame, Object iterable,
103103
@Cached PRaiseNode raiseNode) {
104104
Object clazz = plib.getLazyPythonClass(iterable);
105105
Object attrLenObj = lenNode.execute(clazz);
106-
if (hasLenProfile.profile(attrLenObj != PNone.NO_VALUE && attrLenObj != PNotImplemented.NOT_IMPLEMENTED)) {
106+
if (hasLenProfile.profile(attrLenObj != PNone.NO_VALUE)) {
107107
Object len = null;
108108
try {
109109
len = dispatchGetattribute.executeObject(frame, attrLenObj, iterable);
110110
} catch (PException e) {
111111
e.expect(TypeError, errorProfile);
112112
}
113-
if (len != null) {
113+
if (len != null && len != PNotImplemented.NOT_IMPLEMENTED) {
114114
if (toInt.canBeIndex(len)) {
115115
int intLen = cast.execute(toInt.asIndex(len));
116116
if (intLen < 0) {
@@ -123,14 +123,14 @@ int length(VirtualFrame frame, Object iterable,
123123
}
124124
}
125125
Object attrLenHintObj = lenHintNode.execute(clazz);
126-
if (hasLenghtHintProfile.profile(attrLenHintObj != PNone.NO_VALUE && attrLenHintObj != PNotImplemented.NOT_IMPLEMENTED)) {
126+
if (hasLenghtHintProfile.profile(attrLenHintObj != PNone.NO_VALUE)) {
127127
Object len = null;
128128
try {
129129
len = dispatchGetattribute.executeObject(frame, attrLenHintObj, iterable);
130130
} catch (PException e) {
131131
e.expect(TypeError, errorProfile);
132132
}
133-
if (len != null) {
133+
if (len != null && len != PNotImplemented.NOT_IMPLEMENTED) {
134134
if (toInt.canBeIndex(len)) {
135135
int intLen = cast.execute(toInt.asIndex(len));
136136
if (intLen < 0) {

0 commit comments

Comments
 (0)