Show More
@@ -260,15 +260,19 b" def atomic_writing(path, text=True, encoding='utf-8', **kwargs):" | |||
|
260 | 260 | fileobj.close() |
|
261 | 261 | os.remove(tmp_path) |
|
262 | 262 | raise |
|
263 | else: | |
|
264 | # Written successfully, now rename it | |
|
265 | fileobj.close() | |
|
266 | 263 | |
|
267 | if os.name == 'nt' and os.path.exists(path): | |
|
268 | # Rename over existing file doesn't work on Windows | |
|
269 | os.remove(path) | |
|
264 | # Flush to disk | |
|
265 | fileobj.flush() | |
|
266 | os.fsync(fileobj.fileno()) | |
|
267 | ||
|
268 | # Written successfully, now rename it | |
|
269 | fileobj.close() | |
|
270 | ||
|
271 | if os.name == 'nt' and os.path.exists(path): | |
|
272 | # Rename over existing file doesn't work on Windows | |
|
273 | os.remove(path) | |
|
270 | 274 | |
|
271 |
|
|
|
275 | os.rename(tmp_path, path) | |
|
272 | 276 | |
|
273 | 277 | |
|
274 | 278 | def raw_print(*args, **kw): |
General Comments 0
You need to be logged in to leave comments.
Login now