[issue9136] RuntimeError when profiling Decimal
Mark Dickinson
report at bugs.python.org
Thu Jul 1 13:48:53 CEST 2010
Mark Dickinson <dickinsm at gmail.com> added the comment:
Ah, it looks like 'locals()' is somewhat magical. Its docstring says:
"Update and return a dictionary containing the current scope's local variables."
So I think this explains your (Stefan's) results: in either case, you evaluate locals() (as the target of the for statement) and get a dictionary back. But that dictionary isn't updated to include 'name' and 'val' until you call locals() for a second time. (And possibly there are other activities besides an explicit locals() call that would cause that dict to be updated, but I'm not sure.)
I still don't understand how things work when profile is added into the mix, but I'm willing to accept that the profile module affects locals() in strange and possibly timing-dependent ways.
Anyway, the fix for decimal is clear: get rid of that locals call.
----------
stage: unit test needed -> needs patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9136>
_______________________________________
More information about the Python-bugs-list
mailing list