From 225d98f68f28d294a0f71845b1cb4dacd5ca5716 Mon Sep 17 00:00:00 2001 From: Mahmoud Hashemi Date: Thu, 25 Feb 2016 01:47:02 -0800 Subject: [PATCH] fileutils.replace: bak file for win32 ReplaceFile for slightly better corner case coverage on less featureful filesystems --- boltons/fileutils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/boltons/fileutils.py b/boltons/fileutils.py index 1310b8d..0aa0283 100644 --- a/boltons/fileutils.py +++ b/boltons/fileutils.py @@ -258,8 +258,9 @@ if os.name == 'nt': src = path_to_unicode(src) dst = path_to_unicode(dst) - res = _ReplaceFile(c_wchar_p(dst), c_wchar_p(src), - None, 0, None, None) + bak = dst + u'.bak' + res = _ReplaceFile(c_wchar_p(dst), c_wchar_p(src), c_wchar_p(bak), + 0, None, None) if not res: raise OSError('failed to replace %r with %r' % (dst, src)) return