# HG changeset patch # User Philippe Pepiot # Date 1487668367 -3600 # Node ID a25e52cd8be4e9d359f2dff2a425c9ae7a1a03b6 # Parent eed83dee2c793eff7b70c4f0c20e279856c55e2f [web] fix os.rename usage on windows when destination exists os.rename on windows will raise OSError (or WindowsError subclass) when if destination file already exists. Also check that exception is EEXIST. There is an attempt to fix in f6ba947c but using IOError instead of OSError. Closes #14214794 diff -r eed83dee2c79 -r a25e52cd8be4 cubicweb/web/propertysheet.py --- a/cubicweb/web/propertysheet.py Thu Nov 17 17:26:49 2016 +0100 +++ b/cubicweb/web/propertysheet.py Tue Feb 21 10:12:47 2017 +0100 @@ -19,6 +19,7 @@ __docformat__ = "restructuredtext en" +import errno import re import os import os.path as osp @@ -109,7 +110,9 @@ stream.write(content) try: os.rename(tmpfile, cachefile) - except IOError: + except OSError as err: + if err.errno != errno.EEXIST: + raise # Under windows, os.rename won't overwrite an existing file os.unlink(cachefile) os.rename(tmpfile, cachefile)