Re: [Python-Dev] Tests failing on Windows with TESTFN

2018年7月29日 08:44:14 -0700

On Sun, Jul 29, 2018 at 9:34 AM Tim Golden <[email protected]> wrote:
> For test_mailbox I've experimentally implemented a hybrid tempfile /
> local directory solution. ie I've created a new file on each run, but
> only within the python_<pid> folder which already exists. As long as the
> directory cleans up there should be no leftovers. That's certainly
> helped although my re-run harness has provoked at least one error.
As Eryk noted, the fix for mailbox.py (yes, the stdlib needs fixing in
this case) is quite simple:
diff --git a/Lib/mailbox.py b/Lib/mailbox.py
index 056251d..eb85df1 100644
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -701,8 +701,7 @@ class _singlefileMailbox(Mailbox):
 try:
 os.rename(new_file.name, self._path)
 except FileExistsError:
- os.remove(self._path)
- os.rename(new_file.name, self._path)
+ os.replace(new_file.name, self._path)
 self._file = open(self._path, 'rb+')
 self._toc = new_toc
 self._pending = False
-- 
Jeremy Kloth
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to