[pywin32-bugs] [ pywin32-Patches-3438431 ] ImportFile (Ctrl-I) iter bug
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2011-11-16 09:46:02
|
Patches item #3438431, was opened at 2011-11-15 10:42 Message generated for change (Comment added) made by mhammond You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551956&aid=3438431&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: kxroberto (kxroberto) Assigned to: Nobody/Anonymous (nobody) Summary: ImportFile (Ctrl-I) iter bug Initial Comment: diff -ur --strip _orig/scriptutils.py ./scriptutils.py --- _orig/scriptutils.py 2010-08-25 17:46:40 +0000 +++ ./scriptutils.py 2011-11-15 18:37:26 +0000 @@ -391,7 +391,7 @@ path, modName = os.path.split(pathName) modName, modExt = os.path.splitext(modName) newPath = None - for key, mod in sys.modules.iteritems(): + for key, mod in list(sys.modules.iteritems()): if hasattr(mod, '__file__'): fname = mod.__file__ base, ext = os.path.splitext(fname) solves: Ctrl-I / FileImport: >>> Traceback (most recent call last): File "C:\Python27\Lib\site-packages\pythonwin\pywin\framework\intpyapp.py", line 330, in OnFileImport scriptutils.ImportFile() File "C:\Python27\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 394, in ImportFile for key, mod in sys.modules.iteritems(): RuntimeError: dictionary changed size during iteration win32ui.error: Error in Command Message handler for command ID 36867, Code 0 Note: in pure Python2 "sys.modules.iteritems()" would be ok. But for 2to3 the list(sys.modules.iteritems()) should be consistent ---------------------------------------------------------------------- >Comment By: Mark Hammond (mhammond) Date: 2011-11-16 01:46 Message: oops - just saw your comment :) I admit I like the items() version better as it is more "consistent" WRT other existing code - the fact that 2to3 changes it is actually a feature ---------------------------------------------------------------------- Comment By: Mark Hammond (mhammond) Date: 2011-11-16 01:44 Message: Wouldt sys,modules.items() be even better? ---------------------------------------------------------------------- Comment By: kxroberto (kxroberto) Date: 2011-11-15 10:46 Message: Note: in pure Python2 "sys.modules.items()" would be ok. But for 2to3 the list(sys.modules.iteritems()) should be consistent ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551956&aid=3438431&group_id=78018 |