Skip to content

Commit 78c58c2

Browse files
authored
Merge pull request #4384 from tausbn/python-fix-package-locations
Python: Fix `hasLocationInfo` for packages
2 parents 754d82c + b5d05f9 commit 78c58c2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

python/ql/src/semmle/python/Files.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,12 @@ class Location extends @location {
415415
locations_ast(this, m, startline, startcolumn, endline, endcolumn)
416416
)
417417
)
418+
or
419+
// Packages have no suitable filepath, so we use just the path instead.
420+
exists(Module m | not exists(m.getFile()) |
421+
filepath = m.getPath().getAbsolutePath() and
422+
locations_ast(this, m, startline, startcolumn, endline, endcolumn)
423+
)
418424
}
419425
}
420426

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
| nested/__init__.py:1:6:1:12 | ControlFlowNode for ImportExpr | import | nested/nested.py:0:0:0:0 | Module nested.nested |
22
| nested/nested.py:1:1:1:13 | ControlFlowNode for FunctionExpr | import | nested/nested.py:1:1:1:13 | Function nested |
3-
| test.py:1:6:1:11 | ControlFlowNode for ImportExpr | import | file://:0:0:0:0 | Package nested |
3+
| test.py:1:6:1:11 | ControlFlowNode for ImportExpr | import | nested:0:0:0:0 | Package nested |
44
| test.py:2:1:2:6 | ControlFlowNode for nested | import | nested/nested.py:1:1:1:13 | Function nested |

0 commit comments

Comments
 (0)