[pypy-commit] pypy default: Work around the "text file is busy" error
arigo
noreply at buildbot.pypy.org
Fri Jan 17 12:03:16 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r68711:7812ad72a634
Date: 2014-01-17 12:02 +0100
http://bitbucket.org/pypy/pypy/changeset/7812ad72a634/
Log: Work around the "text file is busy" error
diff --git a/rpython/translator/driver.py b/rpython/translator/driver.py
--- a/rpython/translator/driver.py
+++ b/rpython/translator/driver.py
@@ -591,3 +591,12 @@
if sys.platform == 'win32':
name = name.new(ext='exe')
return name
+
+if os.name == 'posix':
+ def shutil_copy(src, dst):
+ # this version handles the case where 'dst' is an executable
+ # currently being executed
+ shutil.copy(src, dst + '~')
+ os.rename(dst + '~', dst)
+else:
+ shutil_copy = shutil.copy
diff --git a/rpython/translator/test/test_driver.py b/rpython/translator/test/test_driver.py
--- a/rpython/translator/test/test_driver.py
+++ b/rpython/translator/test/test_driver.py
@@ -1,6 +1,6 @@
import py
import os
-from rpython.translator.driver import TranslationDriver
+from rpython.translator.driver import TranslationDriver, shutil_copy
from rpython.tool.udir import udir
def test_ctr():
@@ -74,4 +74,9 @@
assert dst_name.new(ext='dll').read() == 'dll'
assert dst_name.new(purebasename='python27',ext='lib').read() == 'lib'
-
+def test_shutil_copy():
+ a = udir.join('file_a')
+ b = udir.join('file_a')
+ a.write('hello')
+ shutil_copy(str(a), str(b))
+ assert b.read() == 'hello'
More information about the pypy-commit
mailing list