This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author amaury.forgeotdarc
Recipients amaury.forgeotdarc, jerry.seutter, jhylton, nikolasco, tenuki, werneck
Date 2008-06-23.08:54:30
SpamBayes Score 4.1827216e-06
Marked as misclassified No
Message-id <1214211274.67.0.408446515798.issue2378@psf.upfronthosting.co.za>
In-reply-to
Content
The problem is in PyFrame_LocalsToFast.

(As I understand it: "Locals" refers to the locals() dictionary of the
frame; "Fast" refers to an optimization where local variables are stored
in an array. 
Each call to locals() or the trace function normalizes data by copying
the Fast array into the Locals dictionary; with sys.settrace, the user
may modify the locals, so the inverse transformation is done after each
call to the trace function)

When defining a class, PyFrame_FastToLocals does not copy the free
variables from enclosing scopes. This is the goal of r53954 "Do not copy
free variables to locals in class namespaces".
When executing code in the class body, the sys.settrace function is
called with this reduced set of locals().
The problem is that PyFrame_LocalsToFastdoes does not have the same
test, and uses the locals() to update (and clear) the free variables as
well.

I attach a patch that makes PyFrame_LocalsToFast symmetric to
PyFrame_FastToLocals: in the case of a class statement, do not update 
the free variables.
History
Date User Action Args
2008-06-23 08:54:35amaury.forgeotdarcsetspambayes_score: 4.18272e-06 -> 4.1827216e-06
recipients: + amaury.forgeotdarc, jhylton, jerry.seutter, werneck, nikolasco, tenuki
2008-06-23 08:54:35amaury.forgeotdarcsetspambayes_score: 4.18272e-06 -> 4.18272e-06
messageid: <1214211274.67.0.408446515798.issue2378@psf.upfronthosting.co.za>
2008-06-23 08:54:33amaury.forgeotdarclinkissue2378 messages
2008-06-23 08:54:32amaury.forgeotdarccreate