IPython doesn't release object references on exit
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
IPython |
Fix Released
|
Medium
|
Fernando Perez |
Bug Description
# ---- Test IPython exit behavior
class A(object):
def __init__(self):
if os.path.
os.
print '__init__ is here'
def __del__(self):
print '__del__ is here'
open(
a = A()
# --- End test script ---------
When you run the following script from CPython it prints:
__init__ is here
__del__ is here
and creates the __del__.txt file
When you run it from IPython it prints:
__init__ is here
When you exit() or Exit from IPython neothing is printed and no file is created (the file thing is to make sure __del__ is really never called and not that just the output is eaten).
Note that if you call %reset in IPython then everything is Ok.
IPython should do the equivalent of %reset and release all the references it holds before exit. This behavior is important when working with binding objects that rely on __del__. If the current behavior has some use case then I suggest to add a configuration option to IPython to control it.
Changed in ipython: | |
assignee: | nobody → fdo.perez |
importance: | Undecided → Medium |
status: | New → In Progress |
Changed in ipython: | |
status: | Fix Committed → Fix Released |
Have you tested that the normal Python interpreter does not exhibit the
same behavior? I have the fealing this is pretty much unspecified
behavior.
Cheers,
Gaël