Skip to content

Commit 16483f7

Browse files
committed
Python: Add funky call-graph regression
I don't even know how to phrase this :D
1 parent 1e96ced commit 16483f7

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

python/ql/test/experimental/library-tests/CallGraph/InlineCallGraphTest.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pointsTo_found_typeTracker_notFound
1717
| code/func_defined_outside_class.py:39:11:39:21 | ControlFlowNode for _gen() | B._gen |
1818
| code/func_defined_outside_class.py:42:1:42:7 | ControlFlowNode for Attribute() | B._gen.func |
1919
| code/func_defined_outside_class.py:43:1:43:7 | ControlFlowNode for Attribute() | B._gen.func |
20+
| code/funky_regression.py:15:9:15:17 | ControlFlowNode for Attribute() | Wat.f2 |
2021
| code/type_tracking_limitation.py:8:1:8:3 | ControlFlowNode for x() | my_func |
2122
typeTracker_found_pointsTo_notFound
2223
| code/callable_as_argument.py:29:5:29:12 | ControlFlowNode for Attribute() | test_class.InsideTestFunc.sm |
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# When this regression was discovered, we did not resolve the `self.f2()` call after the
2+
# try-except block, but ONLY when passing an attribute to a method, as indicated in the
3+
# other tests below.
4+
5+
class Wat(object):
6+
def f1(self, arg): pass
7+
def f2(self): pass
8+
9+
def func(self, foo):
10+
try:
11+
self.f1(foo.bar) # $ pt,tt=Wat.f1
12+
except Exception as e:
13+
raise e
14+
15+
self.f2() # $ pt=Wat.f2 MISSING: tt=Wat.f2
16+
17+
18+
# ==============================================================================
19+
# variants that we are able to handle
20+
# ==============================================================================
21+
22+
23+
class Works(object):
24+
"not using attribute"
25+
def f1(self, arg): pass
26+
def f2(self): pass
27+
28+
def func(self, foo):
29+
try:
30+
self.f1(foo) # $ pt,tt=Works.f1
31+
except Exception as e:
32+
raise e
33+
34+
self.f2() # $ pt,tt=Works.f2
35+
36+
37+
class AlsoWorks(object):
38+
"no exception"
39+
def f1(self, arg): pass
40+
def f2(self): pass
41+
42+
def func(self, foo):
43+
self.f1(foo.bar) # $ pt,tt=AlsoWorks.f1
44+
45+
self.f2() # $ pt,tt=AlsoWorks.f2
46+
47+
48+
def safe_func(arg):
49+
pass
50+
51+
52+
class Works3(object):
53+
"call to non-self function"
54+
def f1(self, arg): pass
55+
def f2(self): pass
56+
57+
def func(self, foo):
58+
try:
59+
safe_func(foo.bar) # $ pt,tt=safe_func
60+
except Exception as e:
61+
raise e
62+
63+
self.f2() # $ pt,tt=Works3.f2

0 commit comments

Comments
 (0)