mirror of
https://github.com/github/codeql.git
synced 2025-12-22 11:46:32 +01:00
Python: More complex import examples
We need some recursive unwinding to get all of these right
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
# combination of refined and if_then_else
|
||||||
|
|
||||||
|
from trace import *
|
||||||
|
enter(__file__)
|
||||||
|
|
||||||
|
class SOURCE(): pass
|
||||||
|
|
||||||
|
# definition based on "random" choice in this case it will always go the the if-branch,
|
||||||
|
# but our analysis is not able to figure this out
|
||||||
|
if eval("True"):
|
||||||
|
src = SOURCE
|
||||||
|
else:
|
||||||
|
src = SOURCE
|
||||||
|
|
||||||
|
src.foo = 42
|
||||||
|
|
||||||
|
check("src", src, src, globals()) #$ prints=SOURCE
|
||||||
|
|
||||||
|
exit(__file__)
|
||||||
@@ -95,7 +95,10 @@ check("if_then_else_defined", if_then_else_defined, "if_defined", globals()) #$
|
|||||||
|
|
||||||
# check that refined definitions are handled correctly
|
# check that refined definitions are handled correctly
|
||||||
import refined # $ imports=refined as=refined
|
import refined # $ imports=refined as=refined
|
||||||
check("refined.SOURCE", refined.SOURCE, refined.SOURCE, globals()) #$ prints=SOURCE
|
check("refined.SOURCE", refined.SOURCE, refined.SOURCE, globals()) #$ MISSING: prints=SOURCE
|
||||||
|
|
||||||
|
import if_then_else_refined # $ imports=if_then_else_refined as=if_then_else_refined
|
||||||
|
check("if_then_else_refined.src", if_then_else_refined.src, if_then_else_refined.src, globals()) #$ MISSING: prints=SOURCE
|
||||||
|
|
||||||
exit(__file__)
|
exit(__file__)
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ class SOURCE(object): pass
|
|||||||
check("SOURCE", SOURCE, SOURCE, globals()) #$ prints=SOURCE
|
check("SOURCE", SOURCE, SOURCE, globals()) #$ prints=SOURCE
|
||||||
|
|
||||||
SOURCE.foo = 42
|
SOURCE.foo = 42
|
||||||
|
SOURCE.bar = 43
|
||||||
|
SOURCE.baz = 44
|
||||||
|
|
||||||
check("SOURCE", SOURCE, SOURCE, globals()) #$ prints=SOURCE
|
check("SOURCE", SOURCE, SOURCE, globals()) #$ prints=SOURCE
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user