Skip to content

Commit 6aa4491

Browse files
committed
deque: fix __reduce__ builtin
1 parent 268a0e0 commit 6aa4491

File tree

1 file changed

+10
-2
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque

1 file changed

+10
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration;
4848
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
4949
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError;
50+
import static com.oracle.graal.python.nodes.SpecialAttributeNames.__DICT__;
5051
import static com.oracle.graal.python.nodes.SpecialMethodNames.__ADD__;
5152
import static com.oracle.graal.python.nodes.SpecialMethodNames.__CONTAINS__;
5253
import static com.oracle.graal.python.nodes.SpecialMethodNames.__DELITEM__;
@@ -94,6 +95,8 @@
9495
import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetNameNode;
9596
import com.oracle.graal.python.lib.PyNumberAsSizeNode;
9697
import com.oracle.graal.python.lib.PyObjectIsTrueNode;
98+
import com.oracle.graal.python.lib.PyObjectLookupAttr;
99+
import com.oracle.graal.python.lib.PyObjectSizeNode;
97100
import com.oracle.graal.python.nodes.ErrorMessages;
98101
import com.oracle.graal.python.nodes.PGuards;
99102
import com.oracle.graal.python.nodes.PRaiseNode;
@@ -945,12 +948,17 @@ static Object repr(PDeque self) {
945948
abstract static class DequeReduceNode extends PythonUnaryBuiltinNode {
946949

947950
@Specialization(limit = "1")
948-
Object doGeneric(PDeque self,
951+
Object doGeneric(VirtualFrame frame, PDeque self,
949952
@CachedLibrary("self") PythonObjectLibrary lib,
953+
@Cached PyObjectLookupAttr lookupAttr,
954+
@Cached PyObjectSizeNode sizeNode,
950955
@Cached GetClassNode getClassNode,
951956
@Cached ConditionProfile profile) {
952957
Object clazz = getPythonClass(getClassNode.execute(self), profile);
953-
Object dict = lib.hasDict(self) ? lib.getDict(self) : PNone.NONE;
958+
Object dict = lookupAttr.execute(frame, self, __DICT__);
959+
if (PGuards.isNoValue(dict) || sizeNode.execute(frame, dict) <= 0) {
960+
dict = PNone.NONE;
961+
}
954962
Object it = lib.getIterator(self);
955963
PTuple emptyTuple = factory().createEmptyTuple();
956964
int maxLength = self.getMaxLength();

0 commit comments

Comments
 (0)