data = '\n'.join(buf.getvalue().splitlines()) + '\n'
- f = util.atomictempfile(os.path.realpath(path), 'w')
+ # no atomic rename to the existing file that may fail occasionally
+ # for unknown reasons, possibly because of our QFileSystemWatcher or
+ # a virus scanner. also it breaks NTFS symlink (issue #2181).
+ openfile = util.posixfile
+ # atomic rename is reliable on Unix
+ openfile = util.atomictempfile
+ f = openfile(os.path.realpath(path), 'w')