Skip to content

Commit 646349e

Browse files
cosminbascatomasstupka
authored andcommitted
DIR builtin: sort returned list (if a list)
1 parent dcf1b39 commit 646349e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,13 @@ Object locals(VirtualFrame frame, @SuppressWarnings("unused") Object object,
498498

499499
@Specialization(guards = "!isNoValue(object)")
500500
Object dir(VirtualFrame frame, Object object,
501+
@Cached ListBuiltins.ListSortNode sortNode,
501502
@Cached("create(__DIR__)") LookupAndCallUnaryNode dirNode) {
502-
return dirNode.executeObject(frame, object);
503+
Object list = dirNode.executeObject(frame, object);
504+
if (list instanceof PList) {
505+
sortNode.sort(frame, (PList) list);
506+
}
507+
return list;
503508
}
504509
}
505510

0 commit comments

Comments
 (0)