From: moerchendiser2k3 on
Hi at all,

I have a small problem with Py_single_input, that I dont really know
what it
actually does.

I created my own interactive interpreter loop and when I create
objects like

p = TestObject()

this instance is just deleted on Py_Finalize() even I delete the
entire console scope long time before. It seems that Py_single_input
stores the references somewhere else. Could anyone explain me a little
bit what is actually going on here?

Thanks a lot!
Cheers, moerchendiser2k3
From: moerchendiser2k3 on
Hi, any idea?
From: Carl Banks on
On May 30, 3:17 am, moerchendiser2k3 <googler.
1.webmas...(a)spamgourmet.com> wrote:
> Hi, any idea?

Python doesn't guarantee that objects will be deleted at a specific
time. There are different reasons why an object might not be deleted.

In command line mode Python keeps a reference to the most recent
result. I don't know if it happens in general for any
Py_single_input, but you could try to execute a few dummy commands
with Py_single_input to see if it helps. But if you're relying on
that behavior you really need to consider rethinking your problem.

The only foolproof way to ensure that an object has been finalized is
to do it manually (i.e., provide a finalize method to releases
resources).


Carl Banks
From: moerchendiser2k3 on
Hi Carl,

thanks for your help!!

> The only foolproof way to ensure that an object has been finalized is
> to do it manually (i.e., provide a finalize method to releases
> resources).

Yes, you are right, thats what I thought, too. So I wanted to
manually delete the reference, but browsing the sources, seems that
I cant really free it, because its wrapped somewhere
in Py_Finalize() and PyGC_Collect and Py_FreeModules. Any ideas?

Thanks a lot!

Cheers, moerchendiser2k3
From: moerchendiser2k3 on
Hi Carl,

you are right, Python still holds the last
reference. I just set a dummy and thats it :)

Can you tell me where did you get the information from?

Thanks!