Skip to content

Commit ba6ab8f

Browse files
tausbnRasmusWL
andauthored
Python: Expand __main__.py comment
Co-authored-by: Rasmus Wriedt Larsen <[email protected]>
1 parent e647403 commit ba6ab8f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ class File extends Container {
9292
) and
9393
// Exclude files named `__main__.py`. These are often _not_ meant to be run directly, but
9494
// contain this construct anyway.
95+
//
96+
// Their presence in a package (say, `foo`) means one can execute the package directly using
97+
// `python -m foo` (which will run the `foo/__main__.py` file). Since being an entry point for
98+
// execution means treating imports as absolute, this causes trouble, since when run with
99+
// `python -m`, the interpreter uses the usual package semantics.
95100
not this.getShortName() = "__main__.py"
96101
or
97102
// The file contains a `#!` line referencing the python interpreter

0 commit comments

Comments
 (0)