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

Skip to content

Commit 5bfde2c

Browse files
committed
Python: Fix overly broad class attribute node class
This is not strictly necessary, but it was bothering me that this simply covered _all_ nodes that were both definitions and names at the same time. Now it actually encompasses what the documentation claims it does.
1 parent 7f3c6ac commit 5bfde2c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

python/ql/src/semmle/python/dataflow/new/internal/Attributes.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ private class SetAttrCallAsAttrWrite extends AttrWrite, CfgNode {
159159
* Instances of this class correspond to the `NameNode` for `attr`, and also gives access to `value` by
160160
* virtue of being a `DefinitionNode`.
161161
*/
162-
private class ClassAttributeAssignmentNode extends DefinitionNode, NameNode { }
162+
private class ClassAttributeAssignmentNode extends DefinitionNode, NameNode {
163+
ClassAttributeAssignmentNode() { this.getScope() = any(ClassExpr c).getInnerScope() }
164+
}
163165

164166
/**
165167
* An attribute assignment via a class field, e.g.

0 commit comments

Comments
 (0)