nedbat/byterun — pull request #9 by akaptur (2014-06-10 23:06:04+00:00)
Title: Bad scope bug & nested generators

[for discussion, will rebase for merge]

The nested generator bug exposed another bad bug: inner scopes were clobbering the context of their outer scopes, as seen in the [nested name test](https://github.com/akaptur/byterun/compare/nested-generators?expand=1#diff-75e9a536741cd45c0fd1f0d22942a4d7R127). Simply not passing through `self.func_locals` from a Function to `make_frame` fixes the problem and doesn't break any tests under py3. It does cause an inheritance test (`test_calling_subclass_methods`) to fail under py2. (I'm not sure what the solution is for subclassing.)

The generators also suffered from a more serious problem with the stack, which was in the wrong state when resuming a frame. After a close read of the C code with @rntz and a review of other materials like [this blog post](http://tech.blog.aknin.name/2010/07/22/pythons-innards-interpreter-stacks/), I'm convinced that the correct behavior is to have one data stack per frame, not one data stack for the virtual machine.

Many thanks for @rntz for pairing with me on this today!