Skip to content

Commit e9a36b2

Browse files
authored
Merge pull request github#4062 from tausbn/python-fix-unknown-import-star
Approved by yoff
2 parents 8cbd497 + a1a1218 commit e9a36b2

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

python/ql/src/Imports/UnintentionalImport.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ predicate all_defined(ModuleValue exporter) {
2626
}
2727

2828
from ImportStar imp, ModuleValue exporter
29-
where import_star(imp, exporter) and not all_defined(exporter)
29+
where import_star(imp, exporter) and not all_defined(exporter) and not exporter.isAbsent()
3030
select imp,
3131
"Import pollutes the enclosing namespace, as the imported module $@ does not define '__all__'.",
3232
exporter, exporter.getName()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
| imports_test.py:21:1:21:20 | from module import * | Using 'from ... import *' pollutes the namespace |
22
| imports_test.py:22:1:22:32 | from module_without_all import * | Using 'from ... import *' pollutes the namespace |
3+
| imports_test.py:65:1:65:40 | from module_that_does_not_exist import * | Using 'from ... import *' pollutes the namespace |

python/ql/test/query-tests/Imports/general/imports_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,5 @@ def __init__(self):
6161
#Use it
6262
different
6363

64+
# FP reported in https://github.com/github/codeql/issues/4003
65+
from module_that_does_not_exist import *

0 commit comments

Comments
 (0)