Skip to content

Commit be86c9c

Browse files
committed
Python: ObjectAPI to ValueAPI: IterReturnsNonSelf: ObjectAPI.qll: Explains why getAnInferredReturnType is weird for builtins
1 parent 64b1788 commit be86c9c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

python/ql/src/semmle/python/objects/ObjectAPI.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,9 @@ class PythonFunctionValue extends FunctionValue {
637637
ControlFlowNode getAReturnedNode() { result = this.getScope().getAReturnValueFlowNode() }
638638

639639
override ClassValue getAnInferredReturnType() {
640+
/* We have to do a special version of this because builtin functions have no
641+
* explicit return nodes that we can query and get the class of.
642+
*/
640643
result = this.getAReturnedNode().pointsTo().getClass()
641644
}
642645
}
@@ -652,6 +655,9 @@ class BuiltinFunctionValue extends FunctionValue {
652655
override int maxParameters() { none() }
653656

654657
override ClassValue getAnInferredReturnType() {
658+
/* We have to do a special version of this because builtin functions have no
659+
* explicit return nodes that we can query and get the class of.
660+
*/
655661
result = TBuiltinClassObject(this.(BuiltinFunctionObjectInternal).getReturnType())
656662
}
657663
}

0 commit comments

Comments
 (0)