Reopening. The following piece of code changed it behavior between 2.5 and 2.6: def f(): a = 2 class C: exec 'a = 42' abc = a return C print f().abc In 2.6, this returns 2, because static analysis determines that the read of 'a' comes from f's closure, yet the exec gets a new set of locals for the body of C where it stores into. This is highly counter-intuitive. For functions, the issue is resolved by banning exec; the same should (now) happen for classes.
Is there any currently relevant discrepancy between doc and behavior claimed in this issue. As far as I can see, the 2.7 docs for exec and def make no mention of exec being prohibited in def, let alone class statements. Ditto for exec() in 3.x. Anything earlier is out-of-date.