Skip to content

Commit 0bc71d9

Browse files
steve-selkorchi
authored andcommitted
Fix transient error in tee builtins
(cherry picked from commit ff4d74e)
1 parent 76d4966 commit 0bc71d9

File tree

1 file changed

+11
-18
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools

1 file changed

+11
-18
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2025, 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
@@ -78,7 +78,6 @@
7878
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
7979
import com.oracle.truffle.api.dsl.Bind;
8080
import com.oracle.truffle.api.dsl.Cached;
81-
import com.oracle.truffle.api.dsl.Cached.Shared;
8281
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
8382
import com.oracle.truffle.api.dsl.ImportStatic;
8483
import com.oracle.truffle.api.dsl.NeverDefault;
@@ -144,27 +143,21 @@ static Object iter(PTee self) {
144143
@Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
145144
@GenerateNodeFactory
146145
public abstract static class NextNode extends PythonUnaryBuiltinNode {
147-
@Specialization(guards = "self.getIndex() < LINKCELLS")
148-
static Object next(VirtualFrame frame, PTee self,
146+
@Specialization
147+
static Object doIt(VirtualFrame frame, PTee self,
149148
@Bind("this") Node inliningTarget,
150-
@Shared @Cached BuiltinFunctions.NextNode nextNode,
151-
@Shared @Cached PRaiseNode.Lazy raiseNode) {
149+
@Cached PythonObjectFactory factory,
150+
@Cached InlinedConditionProfile indexConditionProfile,
151+
@Cached BuiltinFunctions.NextNode nextNode,
152+
@Cached PRaiseNode.Lazy raiseNode) {
153+
if (indexConditionProfile.profile(inliningTarget, self.getIndex() >= LINKCELLS)) {
154+
self.setDataObj(self.getDataobj().jumplink(factory));
155+
self.setIndex(0);
156+
}
152157
Object value = self.getDataobj().getItem(frame, inliningTarget, self.getIndex(), nextNode, raiseNode);
153158
self.setIndex(self.getIndex() + 1);
154159
return value;
155160
}
156-
157-
@Specialization(guards = "self.getIndex() >= LINKCELLS")
158-
static Object nextNext(VirtualFrame frame, PTee self,
159-
@Bind("this") Node inliningTarget,
160-
@Shared @Cached BuiltinFunctions.NextNode nextNode,
161-
@Cached PythonObjectFactory factory,
162-
@Shared @Cached PRaiseNode.Lazy raiseNode) {
163-
self.setDataObj(self.getDataobj().jumplink(factory));
164-
Object value = self.getDataobj().getItem(frame, inliningTarget, 0, nextNode, raiseNode);
165-
self.setIndex(1);
166-
return value;
167-
}
168161
}
169162

170163
@Builtin(name = J___REDUCE__, minNumOfPositionalArgs = 1)

0 commit comments

Comments
 (0)