Cranking up the microscope (or spelunking deeper, whichever metaphor you prefer), the first thing I'll say is that this code is devilishly complex.
Here's what I've found in the latest pass. First, there's a minor bug at line 353 of pyscript.py [1], where globalNameSpaceModule is set to None when it's self.globalNameSpaceModule which should be set to None. The bug is currently innocuous, as the only invocation of the method in which that assignment is made in this version of the code is from PyScript.Close(), and that method makes the correct assignment: self.globalNameSpaceModule = None It seems to me that there's a more serious problem at line 350 of that module [2], where that same method appears to be invoking a method which does not exist, at least as far as I can determine (bearing in mind that I might not completely understand all the nuances of the tricky code here). self.globalNameSpaceModule.ax._Reset_() Working backward, to see if I can figure out where _Reset_ would be defined, I found this code in the PyScript class: def InitNew(self): framework.COMScript.InitNew(self) import imp self.scriptDispatch = None self.globalNameSpaceModule = imp.new_module("__ax_main__") self.globalNameSpaceModule.__dict__['ax'] = AXScriptAttribute(self) .... It's not completely clear how this method gets invoked (I don't see any calls to it, but I do see that "InitNew" appears as one of the strings in the _public_methods_ array attribute of the base class), but I can tell from my logging that it does get called. However it gets invoked, that means that the _Reset_() call being made above is on an instance of the AXScriptAttribute class, which—as far as I can tell—has no _Reset_() method (and no base class from which it could inherit that method). This is confirmed by an exception which is caught at shutdown time in the PyScript.ResetNamespace() method. The handler for that exception looks like this: except AttributeError: pass # ??? The obvious questions would be * what was the non-existent method expected to do? * could the fact that it didn't get done be causing my problem? The ResetNamespace method has no documentation, so all I would have for answers to those questions would be wild guesses. As a side note, imp.new_module() [3] was deprecated back in Python 3.4. I'm attaching the logs I captured. One set is for a session in which the macro was only invoked once (and therefore didn't result in any observable failures) and the other for the session in which the macro was invoked twice, with the symptoms described earlier in this thread. Please let me know if anything else stands out as potentially useful in the logs. Cheers, Bob [1] https://github.com/SublimeText/Pywin32/blob/master/lib/x64/win32comext/axscript/client/pyscript.py#L353 [2] https://github.com/SublimeText/Pywin32/blob/master/lib/x64/win32comext/axscript/client/pyscript.py#L350 [3] https://docs.python.org/3/library/imp.html#imp.new_module
pyscript-logs.tar
Description: Unix tar archive
_______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32