[Checkins] SVN: zope.testrunner/trunk/src/zope/testrunner/find.py Added support for the new __pycache__ directories in Python 3.2.

Lennart Regebro regebro at gmail.com
Tue Mar 15 17:56:13 EDT 2011


Log message for revision 120955:
  Added support for the new __pycache__ directories in Python 3.2.

Changed:
  U   zope.testrunner/trunk/src/zope/testrunner/find.py

-=-
Modified: zope.testrunner/trunk/src/zope/testrunner/find.py
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/find.py	2011-03-15 17:09:43 UTC (rev 120954)
+++ zope.testrunner/trunk/src/zope/testrunner/find.py	2011-03-15 21:56:13 UTC (rev 120955)
@@ -319,6 +319,20 @@
         return
     for (p, _) in options.test_path:
         for dirname, dirs, files in walk_with_symlinks(options, p):
+            if '__pycache__' in dirs:
+                cached_files = os.listdir(os.path.join(dirname, '__pycache__'))
+                for file in cached_files:
+                    pyfile = file[:-14] + 'py'
+                    if pyfile not in files:
+                        fullname = os.path.join(dirname, '__pycache__', file)
+                        options.output.info("Removing stale bytecode file %s"
+                                            % fullname)
+                        os.unlink(fullname)
+            
+            if '__pycache__' in dirname:
+                # Already cleaned
+                continue
+
             for file in files:
                 if file[-4:] in compiled_suffixes and file[:-1] not in files:
                     fullname = os.path.join(dirname, file)
@@ -326,7 +340,6 @@
                                         % fullname)
                     os.unlink(fullname)
 
-
 def contains_init_py(options, fnamelist):
     """Return true iff fnamelist contains a suitable spelling of __init__.py.
 



More information about the checkins mailing list