def test_outer_scope():
 def outer_scope_test():
  class Referenced:
   pass
  class C:
   if Referenced:
    pass
  Assert(('Referenced' not in C.__dict__.keys()))
 outer_scope_test()
 for x in [None, 'abc', 3]:
  class foo(object, ):
   pass
  a = foo()
  try:
   a.__dict__ = x
   AssertUnreachable()
  except TypeError:
   pass

def test_outer_scope ( ) : def outer_scope_test ( ) : class Referenced : pass class C : if Referenced : pass Assert ( ( 'Referenced' not in C . __dict__ . keys ( ) ) ) outer_scope_test ( ) for x in [ None , 'abc' , 3 ] : class foo ( object , ) : pass a = foo ( ) try : a . __dict__ = x AssertUnreachable ( ) except TypeError : pass
do not automatically include outer scopes in closure scenarios .