Skip to content

Commit 96ac77b

Browse files
committed
Python: fix some consistencies
There is still the case of comprehensions, where TFunction is not defined and so getEnclosingCallable does not exist.
1 parent 19ccb05 commit 96ac77b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPublic.qll

+6-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ newtype TNode =
118118
} or
119119
/** A synthetic node representing a captured variable. */
120120
TCaptureNode(VariableCapture::Flow::SynthesizedCaptureNode cn) or
121-
/** TODO: extende to also cover lambdas */
121+
/** A synthetic node representing the heap of a function. Used for variable capture. */
122122
TLambdaSelfReferenceNode(Function f) {
123123
f = any(VariableCapture::CapturedVariable v).getACapturingScope()
124124
}
@@ -489,7 +489,11 @@ class CaptureNode extends Node, TCaptureNode {
489489

490490
VariableCapture::Flow::SynthesizedCaptureNode getSynthesizedCaptureNode() { result = cn }
491491

492-
override DataFlowCallable getEnclosingCallable() { result = TFunction(cn.getEnclosingCallable()) }
492+
override DataFlowCallable getEnclosingCallable() {
493+
result = TFunction(cn.getEnclosingCallable())
494+
or
495+
result = TModule(cn.getEnclosingCallable())
496+
}
493497

494498
override Location getLocation() { result = cn.getLocation() }
495499

0 commit comments

Comments
 (0)