A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-January/051056.html below:

[Python-Dev] frame.f_locals is writable

[Python-Dev] frame.f_locals is writableShane Holloway (IEEE) shane.holloway at ieee.org
Fri Jan 14 18:19:46 CET 2005
> FWIW, this should work:
> 
>     def replaceFrame(self, ref, oldValue, newValue):
>         for name, value in ref.f_locals.items():
>             if value is oldValue:
>                 exec "ref.f_locals[name] = newValue"
>                 assert ref.f_locals[name] is newValue
> 
> And, no, you don't have to tell me that this is an evil hack. I already 
> know that, since I discovered it earlier this evening by poking around 
> in the C source code for PyFrame_LocalsToFast and then looking to see 
> what code calls that function :)

Yes.  After poking around in Google with PyFrame_LocalsToFast, I found 
some other links to people doing that.  I implemented a direct call 
using ctypes to make the code explicit about what's happening.  I'm just 
glad it is possible now.  Works fine in both 2.3 and 2.4.

Thanks,
-Shane
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4