So, I'm working on frame types, and wrote this code::
def replaceFrame(self, ref, oldValue, newValue): for name, value in ref.f_locals.items(): if value is oldValue: ref.f_locals[name] = newValue assert ref.f_locals[name] is newValue
But unfortunately, the assert fires. f_locals is writable, but not modifiable. I did a bit of searching on Google Groups, and found references to a desire for smalltalk like "swap" functionality using a similar approach, but no further ideas or solutions.
While I am full well expecting the smack of "don't do that", this functionality would be very useful for debugging long-running applications. Is this possible to implement in CPython and ports? Is there an optimization reason to not do this?
At worst, if this isn't possible, direct references in the stack will be wrong above the reload call, and corrected on the invocation of the function. This is a subtle issue with reloading code, and can be documented. And at best there is an effective way to replace it, the system can be changed to a consistent state even in the stack, and I can rejoice. Even if I have to wait until 2.5. ;)
Thanks for your time! -Shane Holloway _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com