# HG changeset patch # User Philippe Pepiot # Date 1487668367 -3600 # Node ID fb03a41139792cd70b48070d354cb2f7e227e194 # Parent 01eeea97e5499ca3c0bebc2eb821b77f840649b6 [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 01eeea97e549 -r fb03a4113979 cubicweb/web/propertysheet.py --- a/cubicweb/web/propertysheet.py Wed Jan 25 14:28:20 2017 +0100 +++ b/cubicweb/web/propertysheet.py Tue Feb 21 10:12:47 2017 +0100 @@ -19,6 +19,7 @@ +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)