[Python-Dev] Accessing value stack

PJ Eby pje at telecommunity.com
Mon Jan 7 21:40:49 CET 2013


On Mon, Jan 7, 2013 at 11:32 AM, Brett Cannon <brett at python.org> wrote:
> On Mon, Jan 7, 2013 at 10:46 AM, Maciej Fijalkowski <fijall at gmail.com> wrote:
>> On Mon, Jan 7, 2013 at 4:22 PM, Oleg Broytman <phd at phdru.name> wrote:
>>> On Mon, Jan 07, 2013 at 03:06:51PM +0100, Dima Tisnek <dimaqq at gmail.com> wrote:
>>>> Hi, is it possible to access the values stored on the stack in Python stack
>>>> machine from Python?
>>>
>>>    In short: it's possible but very much discouraged. Don't hack into
>>> python internals.
>>
>> Is it possible? I claim it's not (from *Python* because obviously data
>> is in memory).
>
> Nope, it's not.

I took that as a challenge, and just tried to do it using
gc.get_referents().  ;-)

Didn't work though...  which actually makes me wonder if that's a bug
in gc.get_referents(), or whether I'm making a bad assumption about
when you'd have to run gc.get_referents() on a frame in order to see
items from the value stack included.  Could this actually be a bug in
frames' GC implementation, or are value stack items not supposed to
count for GC purposes?


More information about the Python-Dev mailing list