On Mon, Jan 7, 2013 at 10:40 PM, PJ Eby <p...@telecommunity.com> wrote: > On Mon, Jan 7, 2013 at 11:32 AM, Brett Cannon <br...@python.org> wrote: >> On Mon, Jan 7, 2013 at 10:46 AM, Maciej Fijalkowski <fij...@gmail.com> wrote: >>> On Mon, Jan 7, 2013 at 4:22 PM, Oleg Broytman <p...@phdru.name> wrote: >>>> On Mon, Jan 07, 2013 at 03:06:51PM +0100, Dima Tisnek <dim...@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?
valustack is a static list in C (it's not a Python list at all) that's stored on the frame. You can't do it that way. gc.get_referrers returns you only python objects (and in fact should return you only python objects that are accessible otherwise, but those details are really implementation-dependent) _______________________________________________ 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