[pywin32-bugs] orphaned proxy objects
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: wzint <zi...@op...> - 2015-11-10 21:26:15
|
PyWin32 build 213 and up exhibit lots of orphaned object.Object proxy objects. How to reproduce: Get a vanilla Python and PyWin32 build >=213 installation (32 or 64 bit). I have used PythonWin 219 and Python 2.7 for this listings. Start PythonWin, open the interactive window. Enter import gc,pprint from pywin.mfc import object enumerate the existing object.Objects gc.collect() pprint.pprint([obj for obj in gc.get_objects() if isinstance(obj,object.Object)]) #one gets a list like this: [<pywin.framework.intpyapp.InteractivePythonApp instance at 0x00C1AC60>, <pywin.framework.intpydde.DDEServer instance at 0x00CA9198>, <pywin.framework.intpydde.DDESystemTopic instance at 0x00CA9620>, <pywin.framework.intpyapp.MainFrame instance at 0x00CA99E0>, <pywin.framework.editor.color.coloreditor.SyntEditTemplate instance at 0x00DCC440>, <pywin.docking.DockingBar.DockingBar instance at 0x00CAEA30>, <pywin.debugger.debugger.DebuggerStackWindow instance at 0x00DD7418>, <pywin.docking.DockingBar.DockingBar instance at 0x00CAE210>, <pywin.debugger.debugger.DebuggerBreakpointsWindow instance at 0x00CAE828>, <pywin.docking.DockingBar.DockingBar instance at 0x00DD7530>, <pywin.debugger.debugger.DebuggerWatchWindow instance at 0x00DD7828>, <pywin.docking.DockingBar.DockingBar instance at 0x00DDC210>, <pywin.framework.interact.CDockedInteractivePython instance at 0x00DDC2B0>, <pywin.framework.winout.WindowOutputDocument instance at 0x00DDC3A0>, <pywin.framework.interact.DockedInteractiveView instance at 0x00DDC828>, <pywin.debugger.debugger.HierListDebugger instance at 0x00DD7440>, <pywin.framework.sgrepmdi.GrepTemplate instance at 0x00E2E710>, <pywin.framework.mdi_pychecker.TheTemplate instance at 0x00E355F8>] #Enter Ctrl-N (File/New) and select python script and immediately close the script window again. Only the interactive window remains. List the existing object.Objects again: gc.collect() pprint.pprint([obj for obj in gc.get_objects() if isinstance(obj,object.Object)]) [<pywin.framework.intpyapp.InteractivePythonApp instance at 0x00C1AC60>, <pywin.framework.intpydde.DDEServer instance at 0x00CA9198>, <pywin.framework.intpydde.DDESystemTopic instance at 0x00CA9620>, <pywin.framework.intpyapp.MainFrame instance at 0x00CA99E0>, <pywin.framework.editor.color.coloreditor.SyntEditTemplate instance at 0x00DCC440>, <pywin.docking.DockingBar.DockingBar instance at 0x00CAEA30>, <pywin.debugger.debugger.DebuggerStackWindow instance at 0x00DD7418>, <pywin.docking.DockingBar.DockingBar instance at 0x00CAE210>, <pywin.debugger.debugger.DebuggerBreakpointsWindow instance at 0x00CAE828>, <pywin.docking.DockingBar.DockingBar instance at 0x00DD7530>, <pywin.debugger.debugger.DebuggerWatchWindow instance at 0x00DD7828>, <pywin.docking.DockingBar.DockingBar instance at 0x00DDC210>, <pywin.framework.interact.CDockedInteractivePython instance at 0x00DDC2B0>, <pywin.framework.winout.WindowOutputDocument instance at 0x00DDC3A0>, <pywin.framework.interact.DockedInteractiveView instance at 0x00DDC828>, <pywin.debugger.debugger.HierListDebugger instance at 0x00DD7440>, <pywin.framework.sgrepmdi.GrepTemplate instance at 0x00E2E710>, <pywin.framework.mdi_pychecker.TheTemplate instance at 0x00E355F8>, <pywin.framework.editor.color.coloreditor.SyntEditDocument instance at 0x00E73B48>, <pywin.framework.editor.color.coloreditor.SplitterFrame instance at 0x00E73CB0>, <pywin.framework.editor.color.coloreditor.SyntEditView instance at 0x00E73F58>, <pywin.framework.editor.ModuleBrowser.BrowserView instance at 0x00E77198>, <pywin.framework.editor.color.coloreditor.SyntEditView instance at 0x00E772D8>, <pywin.framework.editor.document.FileWatchingThread instance at 0x00E73B70>] #Note we have a SyntEditDocument, a SplitterFrame, two SyntEditViews and a FileWatchingThread #Enter Ctrl-N (File/New), select python script four times and immediately close these windows again. List again: gc.collect() pprint.pprint([obj for obj in gc.get_objects() if isinstance(obj,object.Object)]) [<pywin.framework.intpyapp.InteractivePythonApp instance at 0x00C1AC60>, <pywin.framework.intpydde.DDEServer instance at 0x00CA9198>, <pywin.framework.intpydde.DDESystemTopic instance at 0x00CA9620>, <pywin.framework.intpyapp.MainFrame instance at 0x00CA99E0>, <pywin.framework.editor.color.coloreditor.SyntEditTemplate instance at 0x00DCC440>, <pywin.docking.DockingBar.DockingBar instance at 0x00CAEA30>, <pywin.debugger.debugger.DebuggerStackWindow instance at 0x00DD7418>, <pywin.docking.DockingBar.DockingBar instance at 0x00CAE210>, <pywin.debugger.debugger.DebuggerBreakpointsWindow instance at 0x00CAE828>, <pywin.docking.DockingBar.DockingBar instance at 0x00DD7530>, <pywin.debugger.debugger.DebuggerWatchWindow instance at 0x00DD7828>, <pywin.docking.DockingBar.DockingBar instance at 0x00DDC210>, <pywin.framework.interact.CDockedInteractivePython instance at 0x00DDC2B0>, <pywin.framework.winout.WindowOutputDocument instance at 0x00DDC3A0>, <pywin.framework.interact.DockedInteractiveView instance at 0x00DDC828>, <pywin.debugger.debugger.HierListDebugger instance at 0x00DD7440>, <pywin.framework.sgrepmdi.GrepTemplate instance at 0x00E2E710>, <pywin.framework.mdi_pychecker.TheTemplate instance at 0x00E355F8>, <pywin.framework.editor.color.coloreditor.SyntEditDocument instance at 0x00E73B48>, <pywin.framework.editor.color.coloreditor.SplitterFrame instance at 0x00E73CB0>, <pywin.framework.editor.color.coloreditor.SyntEditView instance at 0x00E73F58>, <pywin.framework.editor.ModuleBrowser.BrowserView instance at 0x00E77198>, <pywin.framework.editor.color.coloreditor.SyntEditView instance at 0x00E772D8>, <pywin.framework.editor.document.FileWatchingThread instance at 0x00E73B70>, <pywin.framework.editor.color.coloreditor.SplitterFrame instance at 0x00E8A490>, <pywin.framework.editor.color.coloreditor.SyntEditView instance at 0x00E8A238>, <pywin.framework.editor.ModuleBrowser.BrowserView instance at 0x00E8A3F0>, <pywin.framework.editor.color.coloreditor.SyntEditView instance at 0x00E8A620>, <pywin.framework.editor.color.coloreditor.SplitterFrame instance at 0x00E9D9B8>, <pywin.framework.editor.color.coloreditor.SyntEditView instance at 0x00E9DA30>, <pywin.framework.editor.ModuleBrowser.BrowserView instance at 0x00E9DBE8>, <pywin.framework.editor.color.coloreditor.SyntEditView instance at 0x00E9DC10>, <pywin.framework.editor.color.coloreditor.SplitterFrame instance at 0x00EAE5A8>, <pywin.framework.editor.color.coloreditor.SyntEditView instance at 0x00EAE620>, <pywin.framework.editor.ModuleBrowser.BrowserView instance at 0x00EAE7D8>, <pywin.framework.editor.color.coloreditor.SyntEditView instance at 0x00EAE800>, <pywin.framework.editor.color.coloreditor.SyntEditDocument instance at 0x00EBD0D0>, <pywin.framework.editor.color.coloreditor.SplitterFrame instance at 0x00EBD1C0>, <pywin.framework.editor.color.coloreditor.SyntEditView instance at 0x00EBD238>, <pywin.framework.editor.ModuleBrowser.BrowserView instance at 0x00EBD3F0>, <pywin.framework.editor.color.coloreditor.SyntEditView instance at 0x00EBD418>, <pywin.framework.editor.color.coloreditor.SyntEditDocument instance at 0x00E8A968>, <pywin.framework.editor.color.coloreditor.SyntEditDocument instance at 0x00E9D8A0>, <pywin.framework.editor.color.coloreditor.SyntEditDocument instance at 0x00EAE490>, <pywin.framework.editor.document.FileWatchingThread instance at 0x00EBD0A8>, <pywin.framework.editor.document.FileWatchingThread instance at 0x00E8A738>, <pywin.framework.editor.document.FileWatchingThread instance at 0x00E9D8C8>, <pywin.framework.editor.document.FileWatchingThread instance at 0x00EAE4B8>] # four more sets of orphans # I am particularly concerned about docview.Documents. Define a helper fn=lambda ty: [obj for obj in gc.get_objects() if isinstance(obj,ty)] from pywin.mfc import docview fn(docview.Document) [<pywin.framework.winout.WindowOutputDocument instance at 0x00DDC3A0>, <pywin.framework.editor.color.coloreditor.SyntEditDocument instance at 0x00E73B48>, <pywin.framework.editor.color.coloreditor.SyntEditDocument instance at 0x00EBD0D0>, <pywin.framework.editor.color.coloreditor.SyntEditDocument instance at 0x00E8A968>, <pywin.framework.editor.color.coloreditor.SyntEditDocument instance at 0x00E9D8A0>, <pywin.framework.editor.color.coloreditor.SyntEditDocument instance at 0x00EAE490>] # these have a substantial reference counts import sys sys.getrefcount(fn(docview.Document)[1]) 10 # ...etc, until the end... sys.getrefcount(fn(docview.Document)[-1]) 10 # if one examines the orphans, the _obj_ member is None. So, these objects detatched correctly and # should perish at some time. # I have been using pythonwin up to build 212 in the past, these versions are not affected by this behaviour. Best regards Wolfgang Zint |