1 new changeset in pytest:

http://bitbucket.org/hpk42/pytest/changeset/538a933e724a/
changeset:   538a933e724a
user:        gutworth
date:        2011-07-08 20:17:42
summary:     on windows, rename is not atomic, so utilize exclusive access to 
the file
affected #:  1 file (278 bytes)

--- a/_pytest/assertion/rewrite.py      Fri Jul 08 13:23:12 2011 +0200
+++ b/_pytest/assertion/rewrite.py      Fri Jul 08 13:17:42 2011 -0500
@@ -153,11 +153,16 @@
         # assertion rewriting, but I don't know of a fast way to tell.
         state.trace("failed to compile: %r" % (fn,))
         return None
-    # Dump the code object into a file specific to this process.
-    proc_pyc = pyc + "." + str(os.getpid())
-    _write_pyc(co, fn, proc_pyc)
-    # Atomically replace the pyc.
-    os.rename(proc_pyc, pyc)
+    if sys.platform.startswith("win"):
+        # Windows grants exclusive access to open files and doesn't have atomic
+        # rename, so just write into the final file.
+        _write_pyc(co, fn, pyc)
+    else:
+        # When not on windows, assume rename is atomic. Dump the code object
+        # into a file specific to this process and atomically replace it.
+        proc_pyc = pyc + "." + str(os.getpid())
+        _write_pyc(co, fn, proc_pyc)
+        os.rename(proc_pyc, pyc)
     return co
 
 def _read_pyc(source, pyc):

Repository URL: https://bitbucket.org/hpk42/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
py-svn mailing list
py-svn@codespeak.net
http://codespeak.net/mailman/listinfo/py-svn

Reply via email to