File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
test/query-tests/Statements/general Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 3737 // in module level scope `locals() == globals()`
3838 // see https://docs.python.org/3/library/functions.html#locals
3939 // FP report in https://github.com/github/codeql/issues/6674
40- not a .getScope ( ) instanceof Module
40+ not a .getScope ( ) instanceof Module and
41+ // in class level scope `locals()` reflects the class namespace,
42+ // so modifications do take effect.
43+ not a .getScope ( ) instanceof Class
4144select a , "Modification of the locals() dictionary will have no effect on the local variables."
Original file line number Diff line number Diff line change @@ -174,3 +174,9 @@ def assert_ok(seq):
174174# False positive. ODASA-8042. Fixed in PR #2401.
175175class false_positive :
176176 e = (x for x in [])
177+
178+ # In class-level scope `locals()` reflects the class namespace,
179+ # so modifications do take effect.
180+ class MyClass :
181+ locals ()['x' ] = 43 # OK
182+ y = x
You can’t perform that action at this time.
0 commit comments