Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d6d72dc

Browse files
committed
Python: Account for --respect-init when determining module name.
1 parent 2b72a50 commit d6d72dc

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

python/ql/src/semmle/python/Module.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,15 @@ private predicate legalShortName(string name) {
202202
}
203203

204204
/** Holds if `f` is potentially a source package.
205-
* Does it have an __init__.py file and is it within the source archive?
205+
* Does it have an __init__.py file (or --respect-init=False for Python 2) and is it within the source archive?
206206
*/
207207
private predicate isPotentialSourcePackage(Folder f) {
208208
f.getRelativePath() != "" and
209-
exists(f.getFile("__init__.py"))
209+
(
210+
exists(f.getFile("__init__.py"))
211+
or
212+
py_flags_versioned("options.respect_init", "False", _) and major_version() = 2
213+
)
210214
}
211215

212216
private string moduleNameFromBase(Container file) {

0 commit comments

Comments
 (0)