blob: c3e615505dbe19144881a1dc80643540adc35cfa [file] [log] [blame]
Tor Norbye3a2425a2013-11-04 10:16:08 -08001class C(object):
2 def __init__(self):
3 self.foo = 1
4
5 def f(self):
6 self.bar = 2
7
8 def g(self):
9 if hasattr(self, 'baz'):
10 return self.baz #pass
11 else:
12 return self.spam if hasattr(self, 'spam') else 'eggs' #pass
13
14def main():
15 c = C()
16 c2 = C()
17 try:
18 if hasattr(c2, 'x'):
19 d1 = c.<warning descr="Unresolved attribute reference 'x' for class 'C'">x</warning> #fail
20 d2 = c2.x #pass
21 return d1, d2
22 if hasattr(c, 'spam'):
23 def inner():
24 c = C()
25 return c.<warning descr="Unresolved attribute reference 'spam' for class 'C'">spam</warning> #fail
26 return inner() + c.spam #pass
27 if hasattr(c, 'f'):
28 return c.f() #pass
29 return c.<warning descr="Unresolved attribute reference 'spam' for class 'C'">spam</warning> #fail
30 finally:
31 if hasattr(c, 'close'):
32 c.close() #pass
33