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

Skip to content

Commit 635de7c

Browse files
authored
Merge pull request #1440 from markshannon/python-sanity-improvements
Python sanity improvements
2 parents 8a43fdc + 4a4ed69 commit 635de7c

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ class Module extends Module_, Scope, AstNode {
99
override string toString() {
1010
result = this.getKind() + " " + this.getName()
1111
or
12-
/* No name is defined, which means that this is not on an import path. So it must be a script */
12+
/* No name is defined, which means that this module is not on an import path. So it must be a script */
1313
not exists(this.getName()) and not this.isPackage() and
1414
result = "Script " + this.getFile().getShortName()
15+
or
16+
/* Package missing name, so just use the path instead */
17+
not exists(this.getName()) and this.isPackage() and
18+
result = "Package at " + this.getPath().getAbsolutePath()
1519
}
1620

1721
/** This method will be deprecated in the next release. Please use `getEnclosingScope()` instead.

python/ql/src/semmle/python/types/ModuleObject.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ abstract class ModuleObject extends Object {
3232

3333
override string toString() {
3434
result = "Module " + this.getName()
35+
or
36+
not exists(this.getName()) and
37+
result = this.getModule().toString()
3538
}
3639

3740
/** Gets the named attribute of this module. Using attributeRefersTo() instead

python/ql/test/library-tests/ControlFlow/PointsToSupport/UseFromDefinition.ql

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/**
2-
* @name UseFromDefinition
3-
* @description Insert description here...
4-
* @kind table
5-
* @problem.severity warning
6-
*/
71

82
import python
93

0 commit comments

Comments
 (0)