Skip to content

Commit 8df04c5

Browse files
authored
Merge pull request github#7793 from tausbn/python-fix-bad-TPythonTuple-join-order
Python: Fix bad join order in `TPythonTuple`
2 parents e5b7478 + 4a29095 commit 8df04c5

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

python/ql/lib/semmle/python/objects/TObject.qll

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ newtype TObject =
150150
TBuiltinTuple(Builtin bltn) { bltn.getClass() = Builtin::special("tuple") } or
151151
/** Represents a tuple in the Python source */
152152
TPythonTuple(TupleNode origin, PointsToContext context) {
153-
origin.isLoad() and
154-
context.appliesTo(origin)
153+
exists(Scope s |
154+
context.appliesToScope(s) and
155+
scope_loads_tuplenode(s, origin)
156+
)
155157
} or
156158
/** Varargs tuple */
157159
TVarargsTuple(CallNode call, PointsToContext context, int offset, int length) {
@@ -201,6 +203,13 @@ newtype TObject =
201203
Expressions::subscriptPartsPointsTo(_, _, generic, index)
202204
}
203205

206+
/** Join-order helper for TPythonTuple */
207+
pragma[nomagic]
208+
private predicate scope_loads_tuplenode(Scope s, TupleNode origin) {
209+
origin.isLoad() and
210+
origin.getScope() = s
211+
}
212+
204213
/** Holds if the object `t` is a type. */
205214
predicate isType(ObjectInternal t) {
206215
t.isClass() = true

0 commit comments

Comments
 (0)