#19 WindowsError running clear_comtypes_cache on Python 3.2

closed
nobody
None
5
2011-04-18
2011-04-17
Jason R. Coombs
No

In Python 3.2, compiled Python files are no longer saved as .pyc files, but are instead saved in the __pycache__ folder. This breaks the clear_comtypes_cache script, which assumes only files are found in the cache. The following patch fixes the issue:

Index: clear_comtypes_cache.py

--- clear_comtypes_cache.py (revision 574)
+++ clear_comtypes_cache.py (working copy)
@@ -1,4 +1,6 @@
-import os, sys
+import os
+import sys
+import shutil
from ctypes import windll

def is_cache():
@@ -38,10 +40,7 @@
if directory:
res = windll.user32.MessageBoxA(0, text, title, MB_YESNO|MB_ICONWARNING)
if res == IDYES:
- for f in os.listdir(directory):
- fullpath = os.path.join(directory, f)
- os.remove(fullpath)
- os.rmdir(directory)
+ shutil.rmtree(directory)
print("Removed directory %s" % directory)
else:
print("Directory %s NOT removed" % directory)

Discussion

  • Thomas Heller
    Thomas Heller
    2011-04-18

    Fixed in rev 575.

    Thanks for the patch.

     
  • Thomas Heller
    Thomas Heller
    2011-04-18

    • status: open --> closed