[Scipy-tickets] [SciPy] #1104: Scipy breaks object deletion when imported from a method

SciPy Trac scipy-tickets@scipy....
Thu Jan 28 09:51:56 CST 2010


#1104: Scipy breaks object deletion when imported from a method
-----------------------+----------------------------------------------------
 Reporter:  stephaned  |       Owner:  somebody
     Type:  defect     |      Status:  new     
 Priority:  normal     |   Milestone:  0.8.0   
Component:  Other      |     Version:  0.7.0   
 Keywords:             |  
-----------------------+----------------------------------------------------
 Hi,

 With the following code:
 {{{
 class App:
     def __init__(self):
         import scipy
         ##scipy.pkgload.parent_frame = None

     def __del__(self):
         print "app deleted"

 app = App()
 print "Deleting app"
 del app
 print "Leaving Python"
 }}}

 Here is the output:
 {{{
 Deleting app
 Leaving Python
 app deleted     <-- WRONG
 }}}

 The app object is not deleted by "del app" but when Python leaves.

 This is because "app" has a refcount of 2.

 Going further, I found that "scipy.pkgload.parent_frame = None" solves the
 issue.

 I also tried to transform "scipy.pkgload.parent_frame" to a
 "weakref.proxy", but got "cannot create weak reference to 'frame' object".

 Cheers.
 Stephane

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1104>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list